LINUX
LINUX
===================================================================================
===
//june 22,2022
* vi hi.txt - edit the file
learn gvim commands
1 hi
1 get
1 hi
$ uniq -d hello.txt - only print duplicate lines, one for each group
manjusha@DESKTOP-GG5F932 /cygdrive/C/Users/manjusha/Desktop/hi
$ wc hell.txt
3 21 94 hell.txt
*cmp <filename1> <filename2> -> compare the text in both the files byte by byte and
displays the differ: char no. line no. It won't display anything if the contents
get matched.
*sort <filename>- it displays the content by sorting all the lines in the file in
an alphabetical order based on the 1st charater in each line. But it won't change
the order in the file.
* tac <filename1> -> diplays the content in the reverse order
* exit - to logout
*!! -> repeats last command
// COMPRESSION COMMANDS
*tar cf name.tar <filenames----> -> create a name.tar file
**tar xf name.tar -> extract the files from name.tar file
*tar czf name.tar.gz <filenames----> -> create a name.tar file with gzip
compression
**tar xzf name.tar.gz -> extract the files from name.tar file with gzip compression
*tar cjf name.tar.bz2 <filenames----> -> create a name.tar file with Bzip2
compression
**tar xjf name.tar.bz2 -> extract the files from name.tar file with Bzip2
compression
* gzip <filename> -> compress the file and renames it to filename.gz
*gzip -d filename.gz -> decompress the filename.gz to filename
//SYSTEM INFO
date - shows date and time
cal - shows this months cal
whoami - who you are logged in as
finger user - displays info about user
uname -a -> shows kernel info
man definition - an interface to the system reference manuals
man <command> - shows manual for the command
eg: man ls -> shows manual for lsq
df - shows disk usage
du - shows directory space usage
//SEARCHING
grep "pattern" <filename> - seach for pattern in that file name
grep -r "pattern" <dirname> - seach recursively for pattern in that dir
command | grep "pattern" - search pattern in the output of the comamnd
eg :cat k1.txt | grep "hi"
hi baby
//FILE PERMISSION
chmod octal file - change tthe permission of file to octal which can be found
separately for user, group, world by adding,
4-read(r), 2-write(w) ,1-execute(x)
eg:$ls -all
-rw-r--r--+ 1 manjusha None 4 Nov 27 22:04 h4.txt
-rw-r--r--+ 1 manjusha None 14 Nov 27 23:30 k1.txt
-rw-r--r--+ 1 manjusha None 21 Nov 27 23:31 k2.txt
-rw-r--r--+ 1 manjusha None 10240 Nov 27 22:58 man.tar
-rw-r--r--+ 1 manjusha None 148 Nov 27 23:04 man.tar.bz2
-rw-r--r--+ 1 manjusha None 136 Nov 27 23:02 man.tar.gz
-rw-r--r--+ 1 manjusha None 42 Nov 27 21:50 sv.txt
-rwxrwxrwx+ 1 manjusha None 36 Nov 27 21:52 verilog.txt.gz
manjusha@DESKTOP-GG5F932
/cygdrive/C/Users/manjusha/OneDrive/Desktop/Practice/linux_prac
$ chmod 422 k1.txt
manjusha@DESKTOP-GG5F932
/cygdrive/C/Users/manjusha/OneDrive/Desktop/Practice/linux_prac
$ ls -all
total 27
drwxr-xr-x+ 1 manjusha None 0 Nov 27 23:10 .
drwx------+ 1 manjusha None 0 Nov 27 09:23 ..
-rw-r--r--+ 1 manjusha None 4 Nov 27 22:04 h4.txt
-r---w--w-+ 1 manjusha None 14 Nov 27 23:30 k1.txt
-rw-r--r--+ 1 manjusha None 21 Nov 27 23:31 k2.txt
-rw-r--r--+ 1 manjusha None 10240 Nov 27 22:58 man.tar
-rw-r--r--+ 1 manjusha None 148 Nov 27 23:04 man.tar.bz2
-rw-r--r--+ 1 manjusha None 136 Nov 27 23:02 man.tar.gz
-rw-r--r--+ 1 manjusha None 42 Nov 27 21:50 sv.txt
-rwxrwxrwx+ 1 manjusha None 36 Nov 27 21:52 verilog.txt.gz
manjusha@DESKTOP-GG5F932
/cygdrive/C/Users/manjusha/OneDrive/Desktop/Practice/linux_prac
$ cat k1.txt
hi baby
buddy
manjusha@DESKTOP-GG5F932
/cygdrive/C/Users/manjusha/OneDrive/Desktop/Practice/linux_prac
$ cat >k1.txt
-bash: k1.txt: Permission denied
//PROCESS MANAGEMENT
ps ->display the currently working processes
//file commands
rm file - remove a file
rm -r dir -> remove dir
rm -f file ->force to remove a file
rm -rf dir ->force to remove dir
cp file1 file2 -> copy file1 to file2
cp -r dir1 dir2 -> copy dir1 to dir2
mv file1 file2 -> remove or move
ln -s file link ->create symbolic link to file