Linux Notes
Linux Notes
Linux Notes
Features:
Commands
To know the present directory.
naveen@naveen-VPCEH15EN:~$ pwd
/home/naveen
To know path
To clear
naveen@naveen-VPCEH15EN:~/Desktop$ clear
Ctrl+L
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
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
~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:~$
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
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 “
~