Tuesday, April 23, 2013

some basic commands of linux


For changing directory / to /etc[root@pc1 /]# cd /etcOne step back /etc to /[root@pc1 etc]# cd ..Go to previous working directory[root@pc1 /]# cd -Go to current login user home directory[root@pc1 etc]# cd ~Show the contents of /etc in single color[root@pc1 ~]# dir /etcShow the contents of /etc in different colors with nature of contents[root@pc1 ~]# Ls /etccreate a folder on root partition[root@pc1 ~]# mkdir /diskCreate a folder in /disk[root@pc1 ~]# mkdir /disk/dirCreate multiple folder in multiple directories with single command[root@pc1 ~]# mkdir /etc/dir1 /var/dir2 /usr/dir3Create multiple folder in same directory[root@pc1 ~]# mkdir dir1 dir2 dir3Copy a file in directory[root@pc1 disk]# cp file dirCopy a file from /disk/file and paste it in /disk/dir/[root@pc1 disk]# cp /disk/file /disk/dirCopy a directory with –r option[root@pc1 disk]# cp -r dir dir2Copy a file from /disk/file and paste it in /etc with myfile name[root@pc1 disk]# cp /disk/file /etc/myfileRemove a file[root@pc1 disk]# rm fileRemove a file with forcefully option[root@pc1 disk]# rm –f fileRemove a directory with out –r option and you face will an error[root@pc1 disk]# rm dirRemove a directory with –r option[root@pc1 disk]# rm -r /diskRemove a directory with forcefully option[root@pc1 disk]# rm -rf dirMove /etc/dir1 to /disk/ with different name[root@pc1 disk]# mv /etc/dir1 /disk/mydirRename the folder name mydir to dir[root@pc1 disk]# mv /disk/mydir /disk/dirRename the file name with myfile[root@pc1 disk]# mv file myfileRead a file page by page with less command[root@pc1 disk]# less /etc/grub.confRead a file page by page with more command[root@pc1 disk]# more /etc/qrub.confRead first ten lines of grub.conf[root@pc1 disk]# head /etc/grub.confRead last ten lings of grub.conf[root@pc1 disk]# tail /etc/grub.confRead first 12 lines with –n option[root@pc1 disk]# head -n 12 /etc/grub.confRead last 11 lines with –n option[root@pc1 disk]# tail -n 11 /etc/grub.confCopy the contents of /etc/grub.conf in /disk/file[root@pc1 disk]# cat /etc/grub.conf > /disk/fileAppend the contents /etc/mtab in /etc/file[root@pc1 disk]# cat /etc/mtab >> /disk/fileMerging tow commands with pipe sign output of the first command is input of second command[root@pc1 disk]# cat /etc/squid/squid.conf I moreCount the total lines of squid.conf[root@pc1 disk]# cat /etc/squid/squid.conf I wc -LShow only spool words in squid.conf[root@pc1 disk]# cat /etc/squid/squid.conf I grep spoolFlush the contents of file[root@pc1 disk]# cat /dev/null > /var/log/messages

No comments:

Post a Comment

show