2. nano
vi These editors are used in console mode.
vim
gvim
gedit These editors are used in graphical mode.
Emacs
3. VI editor/ VIM editor:
There are three modes in vi editors:
ex mode(default mode, by pressing escape key, this mode is used for saving and exit )
Insert mode (by pressing insert or I key, this mode is used for editing)
Replace mode (this mode is used for replacing text written, by again pressing insert
or r key)
For saving & exiting document- come on esc mode and write :wq
For setting line numbers in document come on esc mode and write : se nu
For coming on any specific line press line no. and then ‘G’ (ex- 102 then G)
For going at the end of page press ‘G’
For going at the top of page press gg
4. Vim editor is not installed default when you install linux, you have to install vim
editor. It is the enhanced version of vi editor.
# vim/vi filename
Press ‘v’ to come to visual mode, here we can select the matter which we want
to copy , press ‘yy’ to copy (y stands for yank). Press ‘p’ to paste that matter.
Press ‘dd’ to delete a particular line where cursor is.
5. More options (on esc. mode):
I - Starts editing from starting of Line where your cursor is.
a - Starts appending after the character where the cursor is.
A - Starts appending from the end of the line where cursor is.
o - Creates a new line below that line where the cursor is.
O - Creates a new line above the line where the cursor is.
r - Replace only character where cursor is placed.
R - Replace from the cursor start an ends where you want.
6. For replacing many words in a file (for ex- if we have made a file, in that file many
times dog word is written and we want to replace word dog with cat), open file
with vi editor and on esc. Mode type
:%s/dog/cat/g
sed ‘s/dog/cat/g’ filename (show file with replaced word)
7. These commands are called CUPS (Common Unix Printing System)
system-config-printer - To initialize Printer graphically
lpstat - To check the status of printer
lprm <job id> - To cancel the printing
lpq - To check the printing queue status
a2ps - Change normal text to Post Script
ps2pdf - Changes post script to pdf
lpr <filename> <Printer> - Sends printing
8. mount /dev/cdrom /mnt - To mount CD ROM.
mount /dev/device name/mnt - To mount any external device.
mount -t vfat /dev/partition /mnt - To mount fat partition.
mount -t nfs <server IP>:/var/dump /mnt- To mount NFS.
9. blkid - To see device id (ex- hda1, sdb).
du -h <partition> - To check how much partition is used.
lsmod - List of drivers running.
modinfo - Details about running driver
df -h <partition> - To check the free space of a partition.
10. sort <filename> - Short file in a-z format.
sort -d <filename> - Short file in dictionary format.
sort -r <filename> - Short file in z-a format.
tr ‘a-z’ ‘A-Z’ <filename> - Translate file in all capital letters
wc (-l/-w/-c ) <filename> - Word count
(-l for line, -w for word, -c for character)
diff file1 file2 - To see difference between
same looking files.
ps - To check the processing status.
kill -9 PID - To kill the service no. 9.
11. find / -name <filename>- Searches file in /.
find -perm 775 - Searches for files having permission 775.
find -size ± 512k - Searches for files of 512k
find -name *.htm - Searches files having extension .htm.
cut –f1 –d : /etc/passwd - It will show the first column of passwd file
cut –c 1-3 /etc/passwd > new file- Creates a new file.
paste new file file - Pastes the matter of new file in file.
less <filename> - To see a file pagewise.
grep <word> <filename>- To find a particular word or string in a file.
grep –n <word> <filename>- To see the line number in which that word is
locate <name> - Locate all files which has that name.
12. tar -cvf <name> <filesname> - It will take the backup of files as a
single file.
tar -tvf <name> - Show how many files & their name in
the backup file.
tar -xvf <name> - Restore the backup.
tar -rvf <name> <filesname> - It will append the backup.
13. gzip <filename> - It will compress a file.
bzip2 <filename> - It will compress a file.
gunzip <filename>.gz - It will decompress a file.
bunzip2 <filename>.b2z - It will decompress a file.
zcat <filename.gz> - To see the content of compress file
14. To edit or see init level
# vi /etc/inittab
0 = shutdown
1 = single user mode
2 = multiuser mode without NFS support
3 = full multiuser mode
4 = not used
5 = Graphical (x11)
6 = reboot
15. crontab -e -u username
*/1 * * * * echo ‘Hello’ > /dev/tty2 (min, hour, date, month, day)
save file.
service crond restart (now when user login on 2nd
terminal it will get
message hello after every 1 min.)
crontab -l -u username (to see how many crontab are running for user)
crontab -r -u username (deletes the crontab)
crontab –e
11 12 * * * mkdir rahul