Linux Notes

Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 7

Linux

Features:

1.Simplified update for all installed s/w


2.Free s/w licemsing
3.Access to source code
4.Multiple Distributions
5.Better Malware protection

To update $ sudo yum update [java]

Commands
To know the present directory.
naveen@naveen-VPCEH15EN:~$ pwd
/home/naveen

To know the list in dir. (ls)


naveen@naveen-VPCEH15EN:~$ ls
Desktop Documents Downloads Music Pictures Public snap Templates Videos

To know path

To move in to dir. Or change dir


naveen@naveen-VPCEH15EN:~$ cd Desktop
naveen@naveen-VPCEH15EN:~/Desktop$

To clear
naveen@naveen-VPCEH15EN:~/Desktop$ clear
Ctrl+L

To exit from last dir.


naveen@naveen-VPCEH15EN:~/Desktop/1/3/5$ cd ..
naveen@naveen-VPCEH15EN:~/Desktop/1/3$ cd ..
naveen@naveen-VPCEH15EN:~/Desktop/1$ cd ..
naveen@naveen-VPCEH15EN:~/Desktop$

To exit to home stright away


naveen@naveen-VPCEH15EN:~/Desktop/1/3/5$ cd
naveen@naveen-VPCEH15EN:~$

To Display standard output


naveen@naveen-VPCEH15EN:~$ echo my name Nawin
my name Nawin

To display previous given value


naveen@naveen-VPCEH15EN:~$ x=1000
naveen@naveen-VPCEH15EN:~$ echo $x
1000
naveen@naveen-VPCEH15EN:~$

To change to root user


naveen@naveen-VPCEH15EN:~$ su
Password:
su: Authentication failure
naveen@naveen-VPCEH15EN:~$ sudo passwd root
[sudo] password for naveen:
New password:
Retype new password:
passwd: password updated successfully
naveen@naveen-VPCEH15EN:~$ su
Password:
root@naveen-VPCEH15EN:/home/naveen#

To exit from root user


root@naveen-VPCEH15EN:/home/naveen# exit
exit
naveen@naveen-VPCEH15EN:~$

~ pwd -Displays the current working directory of the terminal


~ / - Root dirctory
~echo – Command that writes its aruguments to standard output
~su -used to switch to root user(so that super user permissions can be used to execute commnds)
~su username- used to switch to a different user
~sudo- Excutes only that command with root/ super user privileges
~clear-used to clear terminal screen. Contents will not be deleted but scrolled down.{ctrl+L}
~c- change the directory to the home directory
~cd~ - It change directory to home
~cd/ - Change the dirctory to root dirctory
~cd ..-Change the dirctory to its parents dir.
~cd ‘xx yy’- specify folder name

naveen@naveen-VPCEH15EN:~$ cd /
naveen@naveen-VPCEH15EN:/$ ls
bin dev lib libx32 mnt root snap sys var
boot etc lib32 lost+found opt run srv tmp
cdrom home lib64 media proc sbin swapfile usr
naveen@naveen-VPCEH15EN:/$ cd
naveen@naveen-VPCEH15EN:~$ ls
Desktop Downloads Music Public Templates
Documents File1.txt Pictures snap Videos
naveen@naveen-VPCEH15EN:~$ cd /
naveen@naveen-VPCEH15EN:/bin$ cd ..
naveen@naveen-VPCEH15EN:/$ cd ..
naveen@naveen-VPCEH15EN:/$ cd
naveen@naveen-VPCEH15EN:~$
$ CAT

~cat -

To copy in file.txt
naveen@naveen-VPCEH15EN:~$ ls
Desktop Downloads file3.txt Music Public Templates
Documents File1.txt file4.txt Pictures snap Videos
naveen@naveen-VPCEH15EN:~$ cat > num.txt
12345678910
naveen@naveen-VPCEH15EN:~$ ls
Desktop Downloads file3.txt Music Pictures snap Videos
Documents File1.txt file4.txt num.txt Public Templates
naveen@naveen-VPCEH15EN:~$ cat > num1.txt
11 12 13 14 15 16 17 18 19 20
naveen@naveen-VPCEH15EN:~$ ls
Desktop Downloads file3.txt Music num.txt Public Templates
Documents File1.txt file4.txt num1.txt Pictures snap Videos
naveen@naveen-VPCEH15EN:~$ cat num.txt num1.txt
12345678910
11 12 13 14 15 16 17 18 19 20
naveen@naveen-VPCEH15EN:~$ cat num.txt >> num1.txt
naveen@naveen-VPCEH15EN:~$ cat num.txt
12345678910
naveen@naveen-VPCEH15EN:~$ cat num1.txt
11 12 13 14 15 16 17 18 19 20
12345678910
naveen@naveen-VPCEH15EN:~$
~Cat :t display the content of text files and concatenate files
~cat -n : This add line number to all lines
~cat -b :This add line number to non blank lines
~cat -s : This is used to squeeze blank line into one line
~cat -E: Show $ at the end of lines
~cat > file1.txt : flag (>) create new file and enter text content from terminal
~cat >> file1.txt : flag (>>) used to append text content to an existing file from the terminal

nwin@nwin:~$ cat -n num1.txt


1 123456789
2 123
3 5648
4
5 456
6 789231
7
8 456
nwin@nwin:~$ cat -b num1.txt
1 123456789
2 123
3 5648

4 456
5 789231

6 456
nwin@nwin:~$ cat -s num1.txt
123456789
123
5648

456
789231

456
nwin@nwin:~$
nwin@nwin:~$ cat -E num1.txt
123456789$
123$
5648$
$
456$
789231$
$
456$
nwin@nwin:~$
Working with “grep” Command
~grep option (am) Automobile.txt //Returns results for matching string “options”
~grep -i option (am) Automobile.txt // Case insensitive srtings
~grep -n option (am) Automobile.txt // string along with their line number
~grep -v option (am) Automobile.txt // lines not matching the search
~grep -c option (am) Automobile.txt // matches search string

Example

nwin@nwin:~$ cat >> Automobile.txt


Amber
nwin@nwin:~$ cat Automobile.txt
Honda
yamaha
Lambogini
Ferrari
Maruthi
Aprillia
BMW
Audi
Volkswagen
Kia
Hyundia
Tata
Car
Motorbike
Bus
trucks
Amber
nwin@nwin:~$ grep am Automobile.txt
yamaha
Lambogini
nwin@nwin:~$ grep -i am Automobile.txt
yamaha
Lambogini
Amber
nwin@nwin:~$ grep -I am Automobile.txt
yamaha
Lambogini
nwin@nwin:~$ grep -n am Automobile.txt
2:yamaha
3:Lambogini
nwin@nwin:~$ grep -N am Automobile.txt
grep: invalid option -- 'N'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
nwin@nwin:~$ grep -v am Automobile.txt
Honda
Ferrari
Maruthi
Aprillia
BMW
Audi
Volkswagen
Kia
Hyundia
Tata
Car
Motorbike
Bus
trucks
Amber
nwin@nwin:~$ grep -iv am Automobile.txt
Honda
Ferrari
Maruthi
Aprillia
BMW
Audi
Volkswagen
Kia
Hyundia
Tata
Car
Motorbike
Bus
trucks
nwin@nwin:~$ grep -c am Automobile.txt
2
nwin@nwin:~$ grep -ic am Automobile.txt
3

~grep dh File1.txt File2.txt | sort // search string from both files and sort
~grep dh File1.txt File2.txt sort // sorts the results in reverse order
nwin@nwin:~$ grep am Automobile.txt | sort
Lambogini
yamaha
nwin@nwin:~$ grep am Automobile.txt | sort -r
yamaha
Lambogini
nwin@nwin:~$

~cp : It is used to copy files and directories


~cp -i : It enters interactive mode CLI asks before overwriting files
~cp -u :upadtes the destination file only when source file is diffrent from destination file
~cp-R :Recursive copy for copying directories; copies even hidden files
~cp- v :verbose: prints informative message

nwin@nwin:~$ pwd
/home/nwin
nwin@nwin:~$ ls
Automobile.txt Downloads num0.txt Public
Desktop Music num1.txt Templates
Documents note Pictures Videos
nwin@nwin:~$ cd Desktop/
nwin@nwin:~/Desktop$ ls
note
nwin@nwin:~/Desktop$ cp note /home/nwin/Music/
nwin@nwin:~/Desktop$ cd
nwin@nwin:~$ cd Music
nwin@nwin:~/Music$ ls
note
nwin@nwin:~/Music$

nwin@nwin:~/Desktop$ cp /home/nwin/Music/note22 .
nwin@nwin:~/Desktop$ ls

~mv :It used to move file and directories


~mv-i :Enter interactive mode
~mv-i : updates the destination file only when source file is different from destination file.txt
~mv-v : verbose prints souce and destination file

Delete
~rmdir foldername
~rm filename / foldername
~rm : It remove the specified directory(empty)
~rmdir -p :Removes both the parents and child dirctory
~rmdir -pv : Removes all the parents and sub dir along with the verbose
~ rm -r : Removes even non empty directories
~ rm -rp : Removes non empty dir including parents and subdirectories

user permissions “
~

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy