{"id":95,"date":"2015-04-30T06:22:28","date_gmt":"2015-04-30T06:22:28","guid":{"rendered":"http:\/\/localhost\/blog\/?p=95"},"modified":"2015-04-30T07:55:40","modified_gmt":"2015-04-30T07:55:40","slug":"command-line-utilities","status":"publish","type":"post","link":"http:\/\/www.mandcgroup.in\/blog\/command-line-utilities\/","title":{"rendered":"COMMAND LINE UTILITIES"},"content":{"rendered":"<p style=\"text-align: justify;\">When Linus Torvald introduced Linux and For a long time thereafter, Linux did not have a graphical user interface: It run on character-based terminals only. All the tools ran from a command line.Today the Linux GUI is important, but many people-especially system Administrators-run many command line programs.<\/p>\n<p style=\"text-align: justify;\"><!--more--><\/p>\n<h3 style=\"text-align: justify;\"><strong>SPECIAL CHARACTERS<\/strong><\/h3>\n<ul style=\"text-align: justify;\">\n<li>\u00a0 \u00a0-Escape character<\/li>\n<li>\/ \u00a0 \u00a0-Directory\u00a0separator<\/li>\n<li>. \u00a0 \u00a0-Current director, Also use to \u201chide\u201d files.<\/li>\n<li>.. \u00a0 -Parent directory<\/li>\n<li>~ \u00a0-User\u2019s Home directory<\/li>\n<li>* \u00a0-Represent 0 or more characters in a filename or by itself all files in a directory<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">Example:<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# ls<br \/>\nanaconda-ks.cfg Documents install.log Music Public Videos<br \/>\nDesktop Downloads install.log.syslog Pictures Templates<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# ls inst*<br \/>\ninstall.log install.log.syslog<br \/>\n[root@www www]# ls<br \/>\nhello1.txt hello2.txt hello.txt hellow.<strong>txr<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls hello*<br \/>\nhello1.txt hello2.txt hello.txt hellow.txr<\/p>\n<ul style=\"text-align: justify;\">\n<li>? -Represent a single character in a filename<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">Example:<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nhello1.txt hello2.txt hello.txt hellow.txr<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls hello?txt<br \/>\nhello.txt<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls hello1?txt<br \/>\nhello1.txt<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls hello??txt<br \/>\nhello1.txt hello2.txt<\/p>\n<ul style=\"text-align: justify;\">\n<li>[ ] -Can be used to represent a range of values i.e. [0-9], [A-Z] etc.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">Example:<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nhello1.txt hello2.txt hello.txt hellow.txr<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls hello[0-4].txt<br \/>\nhello1.txt hello2.txt<\/p>\n<ul style=\"text-align: justify;\">\n<li>| -\u201cPipe\u201d, redirect the output of one command into another command.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">Example:<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# ls | more<br \/>\nanaconda-ks.cfg<br \/>\nDesktop<br \/>\nDocuments<br \/>\nDownloads<br \/>\ninstall.log<br \/>\ninstall.log.syslog<br \/>\nMusic<br \/>\nPictures<br \/>\nPublic<br \/>\nTemplates<br \/>\nVideos<br \/>\nwww<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# ls | less<br \/>\nanaconda-ks.cfg<br \/>\nDesktop<br \/>\nDocuments<br \/>\nDownloads<br \/>\ninstall.log<br \/>\ninstall.log.syslog<br \/>\nMusic<br \/>\nPictures<br \/>\nPublic<br \/>\nTemplates<br \/>\nVideos<br \/>\nwww<br \/>\n(END) \u2013(press q to quit)<\/p>\n<h3 style=\"text-align: justify;\"><strong>BASIC UTILITIES<\/strong><\/h3>\n<p style=\"text-align: justify;\">One of the important advantages of Linux is that it comes with thousands of utlities that perform major functions.You will use Linux, whether you use them directly by name from the command line or indirectly from amenu or icon.<\/p>\n<p style=\"text-align: justify;\">The term \u2018directory\u2019 is used extensively in the next sections. A directory is a resource that can hold fils. On other operating system, including Windows, Machintosh, a directory is referred to a folder. So directory is a folder that can hold files.<\/p>\n<p style=\"text-align: justify;\">Note: When you log in on the system, you are currently in your home directory. In this chapter that is only directory you use: All the files you create in this chapter are in your home directory.<\/p>\n<p style=\"text-align: justify;\">\u00a0ALL COMMANDS OR UTILITIES ARE CASE-SENSITIVE.<\/p>\n<p style=\"text-align: justify;\"><strong>ls: LISTS THE NAMES OF FILES<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www ~]# ls<\/p>\n<p style=\"text-align: justify;\">anaconda-ks.cfg Documents install.log<br \/>\nDesktop Downloads install.log.syslog<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# ls -l<br \/>\ntotal 96<br \/>\n-rw\u2014\u2014-. 1 root root 1927 Dec 5 00:43 anaconda-ks.cfg<br \/>\ndrwxr-xr-x. 2 root root 4096 Jan 22 09:04 Desktop<br \/>\ndrwxr-xr-x. 2 root root 4096 Dec 6 06:06 Documents<br \/>\ndrwxr-xr-x. 4 root root 4096 Jan 19 13:31 Downloads<br \/>\n-rw-r\u2013r\u2013. 1 root root 43379 Dec 5 00:43 install.log<br \/>\n-rw-r\u2013r\u2013. 1 root root 11159 Dec 5 00:42 install.log.syslog<br \/>\ndrwxr-xr-x. 2 root root 4096 Dec 5 00:47 Music<br \/>\ndrwxr-xr-x. 2 root root 4096 Jan 12 16:12 Pictures<br \/>\ndrwxr-xr-x. 2 root root 4096 Dec 5 00:47 Public<br \/>\ndrwxr-xr-x. 2 root root 4096 Dec 5 00:47 Templates<br \/>\ndrwxr-xr-x. 3 root root 4096 Dec 29 09:27 Videos<\/p>\n<p style=\"text-align: justify;\"><strong>ls -a: LISTS THE NAMES OF HIDDEN FILES<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www ~]# ls -a<br \/>\n. Documents .icons Public<br \/>\n.. Downloads install.log .pulse<br \/>\n.adobe .elinks install.log.syslog .pulse-cookie<br \/>\nanaconda-ks.cfg .esd_auth .kde .recently-used.xbel<br \/>\n.bash_history .gconf .local .rnd<br \/>\n.bash_logout .gconfd .macromedia .tcshrc<br \/>\n.bash_profile .gimp-2.6 .mousetweaks.pid Templates<br \/>\n.bashrc .gnome2 .mozilla .themes<br \/>\n.cache .gnome2_private Music .thumbnails<br \/>\n.config .gstreamer-0.10 .mysql_history Videos<br \/>\n.cshrc .gtk-bookmarks .nautilus .viminfo<br \/>\n.dbus .gvfs Pictures .vmware<br \/>\nDesktop .ICEauthority .pki<\/p>\n<h3 style=\"text-align: justify;\">touch: EMPTY FILE<\/h3>\n<p style=\"text-align: justify;\">[root@www www]# touch f1<\/p>\n<p style=\"text-align: justify;\">[root@www www]# touch f2 f3<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nf1 f2 f3<\/p>\n<h3 style=\"text-align: justify;\"><strong>cat: CATENATE \u2013 DISPLAY A TEXT FILE<\/strong><\/h3>\n<p style=\"text-align: justify;\">The cat utlity displays the contents of a text file.The name of the command is drived from catenate, which means to join together, one after the other.<\/p>\n<p style=\"text-align: justify;\">Some user\u2019s also use cat command to make a new file as shown below :<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# cat &gt; myfile<br \/>\nThis is the contents of file.<br \/>\nfilename is myfile.Press ctrl+d to save the file after press Enter.<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# cat myfile<br \/>\nThis is the contents of file.<br \/>\nfilename is myfile.Press ctrl+d to save the file after press Enter.<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/localhost\/blog\/wp-content\/uploads\/2015\/04\/command-line-utilities.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-96\" src=\"http:\/\/localhost\/blog\/wp-content\/uploads\/2015\/04\/command-line-utilities.png\" alt=\"command line utilities\" width=\"392\" height=\"220\" srcset=\"http:\/\/www.mandcgroup.in\/blog\/wp-content\/uploads\/2015\/04\/command-line-utilities.png 392w, http:\/\/www.mandcgroup.in\/blog\/wp-content\/uploads\/2015\/04\/command-line-utilities-300x168.png 300w\" sizes=\"auto, (max-width: 392px) 100vw, 392px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\"><strong>\u00a0rm: DELETES A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">The rm (remove) utility deletes a file.<\/p>\n<p style=\"text-align: justify;\">Example :<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nhello1.txt hello2.txt hello.txt hellow.txr<br \/>\n[root@www www]# rm hello1.txt<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nhello2.txt hello.txt hellow.txr<br \/>\n[root@www www]# rm -i hello.txt<br \/>\nrm: remove regular empty file `hello.txt\u2019? y<\/p>\n<p style=\"text-align: justify;\">i stand for interactive form of rm to make sure that you delete only the file you intend to delete.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nhello2.txt hellow.txr<\/p>\n<p style=\"text-align: justify;\">[root@www www]# rm -rf hello2.txt<\/p>\n<p style=\"text-align: justify;\">rf stand for recursively and forcefully.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nhellow.txr<\/p>\n<h3 style=\"text-align: justify;\"><strong>PAGERS<\/strong><\/h3>\n<p style=\"text-align: justify;\"><strong>less ls more: DISPLAYING A TEXT FILE ONE SCREEN AT A TIME<\/strong><\/p>\n<p style=\"text-align: justify;\">When you want to view a file that is longer than one screen, you can use either the less utility or the more utility.<br \/>\nBecause these utilities show one page at a time, they are called pagers.<\/p>\n<p style=\"text-align: justify;\">Although they are very similar, they have subtle differences.<\/p>\n<h3 style=\"text-align: justify;\">Different between less and more utility :<\/h3>\n<p style=\"text-align: justify;\">At the End of the file less displays and EOF (END OF FILE) message and waits for you to press q.<\/p>\n<p style=\"text-align: justify;\">Example:<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# cd \/etc<\/p>\n<p style=\"text-align: justify;\">[root@www etc]# ls | less<\/p>\n<p style=\"text-align: justify;\">abrt<br \/>\nacpi<br \/>\nadjtime<br \/>\nakonadi<br \/>\naliases<br \/>\ncgconfig.conf<br \/>\ncgrules.conf<br \/>\nchkconfig.d<br \/>\ncluster<br \/>\nConsoleKit<br \/>\ncorosync<br \/>\ncron.d<br \/>\n: \u2014\u2014\u2014\u2014\u2014 press spacebar to goto to the next pager.<\/p>\n<p style=\"text-align: justify;\">cron.daily<br \/>\ncron.deny<br \/>\ncron.hourly<br \/>\nDIR_COLORS<br \/>\ndnsmasq.d<br \/>\ndovecot<br \/>\ndracut.conf<br \/>\ndracut.conf.d<br \/>\nfestival<br \/>\nfilesystems<br \/>\nfonts<br \/>\nfprintd.conf<br \/>\nfstab<br \/>\n: \u2014\u2014\u2014\u2014\u2014 press spacebar to goto to the next pager.<\/p>\n<p style=\"text-align: justify;\">gai.conf<br \/>\ngconf<br \/>\ngcrypt<br \/>\ngdm<br \/>\ninittab<br \/>\ninputrc<br \/>\nipa<br \/>\niproute2<br \/>\nissue<br \/>\n: \u2014\u2014\u2014\u2014\u2014 press spacebar to goto to the next pager.<br \/>\nissue.net<br \/>\njava<br \/>\njvm<br \/>\njvm-commmon<br \/>\nkde<br \/>\nlvm<br \/>\nlynx.cfg<br \/>\nlynx.lss<br \/>\nlynx-site.cfg<br \/>\nmail<br \/>\nmailcap<br \/>\nmail.rc<br \/>\nmakedev.d<br \/>\n: \u2014\u2014\u2014\u2014\u2014 press spacebar to goto to the next pager.<\/p>\n<p style=\"text-align: justify;\">ssh<br \/>\nssl<br \/>\nsssd<br \/>\nstatetab<br \/>\nstatetab.d<br \/>\nsudoers<br \/>\nvmware-vix<br \/>\nvsftpd<br \/>\nwarnquota.conf<br \/>\nwgetrc<br \/>\nwpa_supplicant<br \/>\nwvdial.conf<br \/>\nX11<br \/>\nxdg<br \/>\nxinetd.d<br \/>\nxml<br \/>\nyp.conf<br \/>\nyum<br \/>\nyum.conf<br \/>\nyum.repos.d<br \/>\n(END) \u2014\u2014\u2014\u2014\u2014- press q to quit.<br \/>\n[root@www ~]# cd \/etc<\/p>\n<p style=\"text-align: justify;\">[root@www etc]# ls | more<\/p>\n<p style=\"text-align: justify;\">abrt<br \/>\nacpi<br \/>\nadjtime<br \/>\nakonadi<br \/>\naliases<br \/>\naliases.db<br \/>\nalsa<br \/>\nalternatives<br \/>\nanacrontab<br \/>\nasound.conf<br \/>\nat.deny<br \/>\naudisp<br \/>\naudit<br \/>\nautofs_ldap_auth.conf<br \/>\nauto.master<br \/>\nauto.misc<br \/>\nauto.net<br \/>\nauto.smb<br \/>\navahi<br \/>\nbash_completion.d<br \/>\nbashrc<br \/>\nblkid<br \/>\nbluetooth<br \/>\nbonobo-activation<br \/>\ncas.conf<br \/>\ncertmonger<br \/>\ncgconfig.conf<br \/>\ncgrules.conf<br \/>\nchkconfig.d<br \/>\ncluster<br \/>\nConsoleKit<br \/>\ncorosync<br \/>\ncron.d<br \/>\n\u2013More\u2013 \u2014- Press spacebar to goto to the next pager or End of file.<br \/>\n<strong>hostname: DISPLAY THE SYSTEM NAME<\/strong><\/p>\n<p style=\"text-align: justify;\">The hostname command displays the name of the system you are working on.<br \/>\n[root@www ~]# hostname<br \/>\n<a href=\"http:\/\/www.mc712.com\" rel=\"nofollow\">http:\/\/www.mc712.com<\/a><br \/>\n<strong>Temporary Changing the Hostname:<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www ~]# hostname Desktop.example.com<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# hostname<br \/>\nDesktop.example.com<\/p>\n<h4 style=\"text-align: justify;\"><\/h4>\n<h4 style=\"text-align: justify;\"><strong>WORKING WITH FILES:<\/strong><\/h4>\n<p style=\"text-align: justify;\"><strong>cp: COPIES A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">The cp(copy) utlity makes a copy of a file.The utility can copy any file, including text and excecutable program (binar) files. You can use cp to make a backup copy of a file or a copy to experiment with.<\/p>\n<p style=\"text-align: justify;\">Syntax: cp source-file destination-file<\/p>\n<p style=\"text-align: justify;\">Example<\/p>\n<p style=\"text-align: justify;\">[root@Desktop www]# ls<br \/>\nhellow.txr<\/p>\n<p style=\"text-align: justify;\">[root@Desktop www]# cp hellow.txr hellow.txr<br \/>\ncp: `hellow.txr\u2019 and `hellow.txr\u2019 are the same file<\/p>\n<p style=\"text-align: justify;\">[root@Desktop www]# cp hellow.txr myfile1<\/p>\n<p style=\"text-align: justify;\">[root@Desktop www]# ls<br \/>\nhellow.txr myfile1<\/p>\n<p style=\"text-align: justify;\">[root@Desktop www]# cp hellow.txr \/root\/Desktop\/<\/p>\n<p style=\"text-align: justify;\">[root@Desktop www]# cd \/root\/Desktop\/<\/p>\n<p style=\"text-align: justify;\">[root@Desktop Desktop]# ls<br \/>\nhellow.txr<\/p>\n<p style=\"text-align: justify;\">[root@Desktop www]# ls<br \/>\nhellow.txr myfile1<\/p>\n<p style=\"text-align: justify;\">[root@Desktop www]# cp -i hellow.txr myfile1<br \/>\ncp: overwrite `myfile1\u2019? y<\/p>\n<p style=\"text-align: justify;\"><strong>mv: CHANGES THE NAME OF A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">The mv(move) utlity can rename a file without making a copy of it.<\/p>\n<p style=\"text-align: justify;\">Syntax: mv existing-filename new-filename<\/p>\n<p style=\"text-align: justify;\">Example:<\/p>\n<p style=\"text-align: justify;\">[root@Desktop www]# ls<br \/>\nhellow.txr myfile1<\/p>\n<p style=\"text-align: justify;\">[root@Desktop www]# mv myfile1 file<\/p>\n<p style=\"text-align: justify;\">[root@Desktop www]# ls<br \/>\nfile hellow.txr<\/p>\n<p style=\"text-align: justify;\"><strong>lpr: PRINTS A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">The lpr (line printer) utility places one or more files in a print queue for printing. Linux provies print queues so that only one job is printed on a given printer at a time. A queue allows several people or jobs to send output simultaneously to a single printer with the expected results. On machines with access to more than one printer, you can use the -P option to instruct lpr to place the file in the queue for specific printer, including one that is connected to another machine on the network.<\/p>\n<p style=\"text-align: justify;\">The following command prints the file named \u2018hello\u2019. The below command does not specify the printer, the output goes to the default printer, whichis the printer when you have only one printer.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# lpr hello<\/p>\n<p style=\"text-align: justify;\">The next command line prints the same file on the printer named \u2018laser&#8217;:<\/p>\n<p style=\"text-align: justify;\">[root@www www]# lpr -Plaser hello<\/p>\n<p style=\"text-align: justify;\">You can see what jobs are in the print queue by using the lpq utility:<\/p>\n<p style=\"text-align: justify;\">[root@www www]# lpq<br \/>\nlp is ready and printing<br \/>\nRank Owner Job Files Total Size<br \/>\nactive root 2(standard input) 950111 bytes<\/p>\n<p style=\"text-align: justify;\">In this example, root has one job that is being printed; no other jobs are in the queue.You can use the Job number (2 in this case) with the \u2018lprm utility to remove the job from the print queue and stop it from printing.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# lprm 2<\/p>\n<p style=\"text-align: justify;\">You can send more than one file to the printer with a single command. The following command line prints three files on the printer named laser :<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nhello hellow.txr<\/p>\n<p style=\"text-align: justify;\">[root@www www]# lpr -Plaser hello hello<br \/>\nhello hellow.txr<br \/>\n<strong>grep: GLOBAL REGULAR EXPRESSION PRINT \u2013 FINDS A STRING<\/strong><\/p>\n<p style=\"text-align: justify;\">The grep (GLOBAL REGULAR EXPRESSION PRINT) utility searches throgh one or more files to see whether any contain a specified string of characters. It does not change the file it searches but simply displays each line that contains the string.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# cat &gt; introduction<\/p>\n<p style=\"text-align: justify;\">My name is Manish Chauhan.<br \/>\nRHEL stand for Redhat Enterprise linux.<br \/>\nLatest version of redhat is 6.0<br \/>\nLinux is open source operating system<br \/>\n(ctrl+d)<\/p>\n<p style=\"text-align: justify;\">[root@www www]# cat introduction<\/p>\n<p style=\"text-align: justify;\">My name is Manish Chauhan.<br \/>\nRHEL stand for Redhat Enterprise Linux.<br \/>\nLatest version of redhat is 6.0<br \/>\nLinux is open source operating system<\/p>\n<p style=\"text-align: justify;\">[root@www www]# grep \u2018Linux\u2019 introduction<\/p>\n<p style=\"text-align: justify;\">RHEL stand for Redhat Enterprise Linux.<br \/>\nLinux is open source operating system<br \/>\n<strong>head: DISPLAYS THE BEGINNING OF A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">By default the head utility displays the first 10 lines of a file. You can use head to help you remember what a particular file contains.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# cat months<br \/>\njan<br \/>\nfeb<br \/>\nmarch<br \/>\napril<br \/>\nmay<br \/>\njune<br \/>\njuly<br \/>\naug<br \/>\nsept<br \/>\noct<br \/>\nnov<br \/>\ndec<br \/>\n[root@www www]# head months<br \/>\njan<br \/>\nfeb<br \/>\nmarch<br \/>\napril<br \/>\nmay<br \/>\njune<br \/>\njuly<br \/>\naug<br \/>\nsept<br \/>\noct<br \/>\n[root@www www]# head -3 months<br \/>\njan<br \/>\nfeb<br \/>\nmarch<\/p>\n<p style=\"text-align: justify;\"><strong>tail: DISPLAYS THE END OF A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">The tail utility is similar to head but by default displays the last 10 lines of a file.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# tail months<br \/>\nmarch<br \/>\napril<br \/>\nmay<br \/>\njune<br \/>\njuly<br \/>\naug<br \/>\nsept<br \/>\noct<br \/>\nnov<br \/>\ndec<\/p>\n<p style=\"text-align: justify;\">[root@www www]# tail -2 months<br \/>\nnov<br \/>\ndec<\/p>\n<p style=\"text-align: justify;\"><strong>sort: Displays A FILE IN ORDER<\/strong><\/p>\n<p style=\"text-align: justify;\">The sort utility displays the contents of a file in order by lines but does not change the original file.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# sort months<\/p>\n<p style=\"text-align: justify;\">april<br \/>\naug<br \/>\ndec<br \/>\nfeb<br \/>\njan<br \/>\njuly<br \/>\njune<br \/>\nmarch<br \/>\nmay<br \/>\nnov<br \/>\noct<br \/>\nsept<\/p>\n<p style=\"text-align: justify;\"><strong>uniq: REMOVES DUPLICATE LINES FROM A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">The uniq(unique) utility displays a file, skipping adjacent duplicate lines, but does not change the original file. If a file contains a list of names and has two successive enteries for the same person, uniq skips the extra line.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# cat linux<br \/>\nserver<br \/>\nserver<br \/>\nyum<br \/>\nyum<br \/>\ndns<br \/>\nyum<br \/>\nserver<br \/>\ndns<br \/>\ndns<\/p>\n<p style=\"text-align: justify;\">[root@www www]# uniq linux<br \/>\nserver<br \/>\nyum<br \/>\ndns<br \/>\nyum<br \/>\nserver<br \/>\ndns<br \/>\n[root@www www]# sort -n linux<br \/>\ndns<br \/>\ndns<br \/>\ndns<br \/>\nserver<br \/>\nserver<br \/>\nserver<br \/>\nyum<br \/>\nyum<br \/>\nyum<\/p>\n<p style=\"text-align: justify;\">[root@www www]# sort -u linux<br \/>\ndns<br \/>\ndns<br \/>\nserver<br \/>\nyum<br \/>\nyum<\/p>\n<p style=\"text-align: justify;\">(Remove duplicate lines and sort the contents of file name \u2018linux\u2019)<br \/>\n<strong>diff: COMPARES TWO FILES<\/strong><\/p>\n<p style=\"text-align: justify;\">The diff (difference) utility compares two files and displays a list of the differences between them.This utility does not change either file, so it is useful when you want to compare two versions of a letter or a report or two versions of the source code for a program.<\/p>\n<p style=\"text-align: justify;\">The diff utility with the -u (unified output format) option first displays two lines indicating which of the files you are comparing will be denoted by a plus(+) and which by a minus sign(-).A minus sign indicates the \u2018file1\u2032 ; a plus sign indicates the \u2018file2\u2032.<\/p>\n<p style=\"text-align: justify;\">The diff -u command breaks long, multiline text into Hunks.<br \/>\nEach hunk is preceded by a line starting and ending with two at signs (@@).<br \/>\nThe hunk identifier indicates the starting line number and the number of lines from each file for this hunk.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# cat file1<br \/>\nHello<br \/>\nHow<\/p>\n<p style=\"text-align: justify;\">[root@www www]# cat file2<br \/>\nHello<br \/>\nare<br \/>\n[root@www www]# diff -u file1 file2<br \/>\n\u2014 file1 2013-01-22 19:38:15.043744843 +0530<br \/>\n+++ file2 2013-01-22 19:38:32.550744879 +0530<br \/>\n@@ -1,2 +1,2 @@ (-1 is file1 , +1 is file2 and 2 words are present)<br \/>\nHello (no sign means Hello is common word in both files)<br \/>\n-How (minus sign indicates the \u2018file1\u2032)<br \/>\n\u2013<br \/>\n+are (plus sign indicates the \u2018file2\u2032.<br \/>\n<strong>file: TESTS THE CONTENTS OF A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">You can use the \u2018file\u2019 utility to learn about the contents of any file on a linux filesystem without having to open and examine the file yourself.<\/p>\n<p style=\"text-align: justify;\">[root@www Desktop]# file image.png<br \/>\nimage.png: PNG image data, 673 x 378, 8-bit\/color RGB, non-interlaced<\/p>\n<p style=\"text-align: justify;\">[root@www Desktop]# file hellow.txr<br \/>\nhellow.txr: empty<\/p>\n<p style=\"text-align: justify;\">[root@www Desktop]# cat &gt; hello<br \/>\nabc<\/p>\n<p style=\"text-align: justify;\">[root@www Desktop]# file hello<br \/>\nhello: ASCII text<\/p>\n<h4 style=\"text-align: justify;\">|(PIPE): COMMUNICATES BETWEEN PROCESSES<\/h4>\n<p style=\"text-align: justify;\">A process is the excecution of a command by Linux. Communication between processes is one of the hallmarks of UNIX\/Linux.<br \/>\nA pipe (written as vertical bar, |, on the command line and appearing as a solid or broken vertical line on keyboards)provides the simplest form of this kind of communication.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# cat months | head -4<br \/>\njan<br \/>\nfeb<br \/>\nmarch<br \/>\napril<br \/>\n<strong>echo: DISPLAYS TEXT<\/strong><\/p>\n<p style=\"text-align: justify;\">The echo utility copies anything you put on the command line, after echo,to the screen<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nf1 f2 f3<\/p>\n<p style=\"text-align: justify;\">[root@www www]# echo \u201cHELLO WORLD\u201d<br \/>\nHELLO WORLD<\/p>\n<p style=\"text-align: justify;\">[root@www www]# echo \u2018HELLO WORLD\u2019<br \/>\nHELLO WORLD<\/p>\n<p style=\"text-align: justify;\">[root@www www]# echo mc712 *<br \/>\nmc712 f1 f2 f3<br \/>\n<strong>DIFFERENCE BETWEEN \u201ccat echo\u201d and \u201cecho cat\u201d UTILITY :<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www www]# cat &gt; echo<br \/>\nWith the help of cat we create a new file echo.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# cat echo<br \/>\nWith the help of cat we create a new file echo.<\/p>\n<p style=\"text-align: justify;\">{ cat echo utility display the contents of file having name echo. }<\/p>\n<p style=\"text-align: justify;\">[root@www www]# echo cat<br \/>\ncat<\/p>\n<p style=\"text-align: justify;\"><strong>date: DISPLAYS THE TIME AND DATE<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www www]# cal<br \/>\nJanuary 2013<br \/>\nSu Mo Tu We Th Fr Sa<br \/>\n1 2 3 4 5<br \/>\n6 7 8 9 10 11 12<br \/>\n13 14 15 16 17 18 19<br \/>\n20 21 22 23 24 25 26<br \/>\n27 28 29 30 31<\/p>\n<p style=\"text-align: justify;\">[root@www www]# cal 2014<\/p>\n<p style=\"text-align: justify;\">[root@www www]# date<\/p>\n<p style=\"text-align: justify;\">Tue Jan 22 21:11:11 IST 2013<\/p>\n<p style=\"text-align: justify;\">day month date Time YEAR<br \/>\n[root@www ~]# date \u2013help<\/p>\n<ul style=\"text-align: justify;\">\n<li>%A locale\u2019s full weekday name (e.g., Sunday)<\/li>\n<li>%B locale\u2019s full month name (e.g., January)<\/li>\n<li>%C century; like %Y, except omit last two digits (e.g., 20)<\/li>\n<li>%D date; same as %m\/%d\/%y<\/li>\n<li>%a locale\u2019s abbreviated weekday name (e.g., Sun)<\/li>\n<li>%b locale\u2019s abbreviated month name (e.g., Jan)<\/li>\n<li>%c locale\u2019s date and time (e.g., Thu Mar 3 23:05:25 2005)<\/li>\n<li>%d day of month (e.g, 01)<\/li>\n<li>%e day of month, space padded; same as %_d<\/li>\n<li>%F full date; same as %Y-%m-%d<\/li>\n<li>%g last two digits of year of ISO week number (see %G)<\/li>\n<li>%G year of ISO week number (see %V); normally useful only with %V<\/li>\n<li>%h same as %b<\/li>\n<li>%H hour (00..23)<\/li>\n<li>%I hour (01..12)<\/li>\n<li>%j day of year (001..366)<\/li>\n<li>%k hour ( 0..23)<\/li>\n<li>%l hour ( 1..12)<\/li>\n<li>%m month (01..12)<\/li>\n<li>%M minute (00..59)<\/li>\n<li>%n a newline<\/li>\n<li>%N nanoseconds (000000000..999999999)<\/li>\n<li>%p locale\u2019s equivalent of either AM or PM; blank if not known<\/li>\n<li>%P like %p, but lower case<\/li>\n<li>%r locale\u2019s 12-hour clock time (e.g., 11:11:04 PM)<\/li>\n<li>%R 24-hour hour and minute; same as %H:%M<\/li>\n<li>%s seconds since 1970-01-01 00:00:00 UTC<\/li>\n<li>%S second (00..60)<\/li>\n<li>%t a tab<\/li>\n<li>%T time; same as %H:%M:%S<\/li>\n<li>%u day of week (1..7); 1 is Monday<\/li>\n<li>%U week number of year, with Sunday as first day of week (00..53)<\/li>\n<li>%V ISO week number, with Monday as first day of week (01..53)<\/li>\n<li>%w day of week (0..6); 0 is Sunday<\/li>\n<li>%W week number of year, with Monday as first day of week (00..53)<\/li>\n<li>%x locale\u2019s date representation (e.g., 12\/31\/99)<\/li>\n<li>%X locale\u2019s time representation (e.g., 23:13:48)<\/li>\n<li>%y last two digits of year (00..99)<\/li>\n<li>%Y year<\/li>\n<li>%z +hhmm numeric timezone (e.g., -0400)<\/li>\n<li>%:z +hh:mm numeric timezone (e.g., -04:00)<\/li>\n<li>%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)<\/li>\n<li>%:::z numeric time zone with : to necessary precision (e.g., -04, +05:30)<\/li>\n<li>%Z alphabetic time zone abbreviation (e.g., EDT)<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">[root@www ~]# date +\u201d%A %B %C %D\u201d<br \/>\nTuesday January 20 01\/22\/13<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# date +\u201d%a %b %c %d\u201d<br \/>\nTue Jan Tue 22 Jan 2013 09:26:40 PM IST 22<\/p>\n<h3 style=\"text-align: justify;\">s<strong>cript: Records a Linux Session<\/strong><\/h3>\n<p style=\"text-align: justify;\">The script utility all or part of a login session, including your input and the system\u2019s responses. This utility is useful only from character-based devices, such as a termnal or a terminal emulator. It does capture a session with vim; however because vim uses control characters to position the cursor and display different type-faces, such as bold, the output will be difficult to read and may not be useful.<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# script<br \/>\nScript started, file is typescript<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# echo mc712<br \/>\nmc712<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# cat &gt; newfile<br \/>\ncontents of file<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# cat newfile<br \/>\ncontents of file<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# exit<br \/>\nexit<br \/>\nScript done, file is typescript<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# ls<br \/>\ntypescript<br \/>\n[root@www ~]# cat typescript<\/p>\n<p style=\"text-align: justify;\">Script started on Tue 22 Jan 2013 09:35:00 PM IST<br \/>\n[root@www ~]# echo mc712<br \/>\nmc712<br \/>\n[root@www ~]# cat &gt; newfile<br \/>\ncontents of file<br \/>\n[root@www ~]# cat newfile<br \/>\ncontents of file<br \/>\n[root@www ~]# exit<br \/>\nexit<\/p>\n<p style=\"text-align: justify;\">Script done on Tue 22 Jan 2013 09:36:01 PM IST<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/localhost\/blog\/wp-content\/uploads\/2015\/04\/command-line-utilities1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-97\" src=\"http:\/\/localhost\/blog\/wp-content\/uploads\/2015\/04\/command-line-utilities1.png\" alt=\"command line utilities1\" width=\"448\" height=\"265\" srcset=\"http:\/\/www.mandcgroup.in\/blog\/wp-content\/uploads\/2015\/04\/command-line-utilities1.png 448w, http:\/\/www.mandcgroup.in\/blog\/wp-content\/uploads\/2015\/04\/command-line-utilities1-300x177.png 300w\" sizes=\"auto, (max-width: 448px) 100vw, 448px\" \/><\/a><\/p>\n<h4 style=\"text-align: justify;\"><strong>unix2dos: CONVERTS LINUX FILES TO WINDOWS FORMAT<\/strong><\/h4>\n<p style=\"text-align: justify;\">If you want to share a text file that you created on a Linux system with someone on a Window system, you need to convert the file before the person on the Windows system can read it easily.The unix2dos utility converts a Linux text file so that it can be read on a Windows system.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# unix2dos hello<br \/>\nunix2dos: converting file hello to DOS format \u2026<br \/>\n<strong>dos2unix: CONVERTS WINDOWS FORMAT TO LINUX FILES<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www www]# dos2unix hello<br \/>\ndos2unix: converting file hello to UNIX format \u2026<\/p>\n<h4 style=\"text-align: justify;\"><strong>COMPRESSING AND ARCHIVING FILES<\/strong><\/h4>\n<p style=\"text-align: justify;\">To reduce the amount of disk space you use without removing the file entirely, you can compress the file without losing any information it holds.Also you may frequently download compress files from the internet.The utilities described in this section is compress and decompress files.<\/p>\n<p style=\"text-align: justify;\"><strong>bzip2: COMPRESSES A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\necho f2 file1 hello introduction months<br \/>\nf1 f3 file2 hellow.txr linux nths<\/p>\n<p style=\"text-align: justify;\">[root@www www]# bzip2 hello<\/p>\n<p style=\"text-align: justify;\">or<\/p>\n<p style=\"text-align: justify;\">[root@www www]# bzip2 -v months<br \/>\nmonths: 0.648:1, 12.351 bits\/byte, -54.39% saved, 57 in, 88 out.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\necho f2 file1 hello.bz2 introduction months.bz2<br \/>\nf1 f3 file2 hellow.txr linux nths<br \/>\n[root@www www]# ls<br \/>\necho f2 file1 hello<\/p>\n<p style=\"text-align: justify;\">[root@www www]# bzip2 *<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\necho.bz2 f2.bz2 file1.bz2 hello.bz2<\/p>\n<p style=\"text-align: justify;\">(.bz2 is filename extension after compressing the file)<br \/>\n<strong>bunzip2 and bzcat: DECOMPRESS A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nhello.bz2 months.bz2<\/p>\n<p style=\"text-align: justify;\">[root@www www]# bunzip2 hello.bz2<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nhello<\/p>\n<p style=\"text-align: justify;\">[root@www www]# bzcat months.bz2<br \/>\njan<br \/>\nfeb<br \/>\nmarch<br \/>\napril<br \/>\nmay<br \/>\njune<br \/>\njuly<br \/>\naug<br \/>\nsept<br \/>\noct<br \/>\nnov<br \/>\ndec<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nhello months.bz2<\/p>\n<p style=\"text-align: justify;\">After bzcat is run, the contents of months.bz2 is unchanged; the file is still stored on the disk in compressed form<\/p>\n<p style=\"text-align: justify;\"><strong>bzip2recover<\/strong> : The bzip2recover utility supports limited data recovery from media errors.Give the command bzip2recover followed by the name from which you can want to try to recover data.<\/p>\n<p style=\"text-align: justify;\"><strong>gzip: COMPRESSES A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">The gzip (GNU zip) utility is older and less efficient than bzip2.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nmonths<\/p>\n<p style=\"text-align: justify;\">[root@www www]# gzip months<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nmonths.gz<\/p>\n<p style=\"text-align: justify;\">(.gz is filename extension after compressing the file)<\/p>\n<p style=\"text-align: justify;\">[root@www www]# zcat months.gz<br \/>\njan<br \/>\nfeb<br \/>\nmarch<br \/>\napril<br \/>\nmay<br \/>\njune<br \/>\njuly<br \/>\naug<br \/>\nsept<br \/>\noct<br \/>\nnov<br \/>\ndec<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nmonths.gz<br \/>\n<strong>gunzip: DECOMPRESSES A FILE<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nmonths.gz<\/p>\n<p style=\"text-align: justify;\">[root@www www]# gunzip months.gz<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nmonths<br \/>\n<strong>DIFFERENT BETWEEN gzip and zip.<\/strong><\/p>\n<p style=\"text-align: justify;\">Do not confuse gzip and gunzip with the zip and unzip utilities. These last two are used to pack and unpack zip archives containing several files compressed into a single file that has been imported from or is being exported to windows.The zip utility constructs a zip archive, whereas unzip unpacks zip archives. The zip and unzip utilities are compatible with PKZIP, a windows compress and archive program.<\/p>\n<p style=\"text-align: justify;\"><strong>zip utility<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\necho f2 file1 hello introduction months<br \/>\nf1 f3 file2 hellow.txr linux<br \/>\nnths<br \/>\n[root@www www]# zip folder file1<br \/>\nadding: file1 (stored 0%)<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\necho f2 file1 folder.zip hellow.txr linux nths<br \/>\nf1 f3 file2 hello introduction months<\/p>\n<p style=\"text-align: justify;\">[root@www www]# zip folder2 file1 f2 linux months<br \/>\nadding: file1 (stored 0%)<br \/>\nadding: f2 (stored 0%)<br \/>\nadding: linux (deflated 40%)<br \/>\nadding: months (deflated 4%)<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\necho f2 file1 folder2.zip hello introduction months<br \/>\nf1 f3 file2 folder.zip hellow.txr linux nths<br \/>\n<strong>unzip utility<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www mc712]# ls<br \/>\nfolder.zip<\/p>\n<p style=\"text-align: justify;\">[root@www mc712]# unzip folder.zip<br \/>\nArchive: folder.zip<br \/>\nextracting: file1<\/p>\n<p style=\"text-align: justify;\">[root@www mc712]# ls<br \/>\nfile1 folder.zip<\/p>\n<p style=\"text-align: justify;\"><strong>tar: PACKS AND UNPACKS FILES<\/strong><\/p>\n<p style=\"text-align: justify;\">The tar utility performs many functions. Its name is short for TAPE ARCHIVE, as it original function was to create and read archive and backup tapes. Today it is use to create a single file (called a tar file) from multiple files or directory hierarchies and to extract files from a tar file.<\/p>\n<p style=\"text-align: justify;\"><strong>PACKS<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\necho f1 f2 f3 file1 file2 hello hellow.txr introduction linux months<\/p>\n<p style=\"text-align: justify;\">[root@www www]# tar -cvf backup.tar f1 f2 f3<br \/>\nf1<br \/>\nf2<br \/>\nf3<\/p>\n<p style=\"text-align: justify;\">[root@www www]# ls<br \/>\nbackup.tar echo f1 f2 f3 file1 file2 hello hellow.txr introduction linux months<br \/>\n<strong>UNPACKS<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www mc712]# ls<br \/>\nbackup.tar<\/p>\n<p style=\"text-align: justify;\">[root@www mc712]# tar -xvf backup.tar<br \/>\nf1<br \/>\nf2<br \/>\nf3<\/p>\n<p style=\"text-align: justify;\">[root@www mc712]# ls<br \/>\nbackup.tar f1 f2 f3<br \/>\nPOINTS TO REMEMBER:<\/p>\n<ul style=\"text-align: justify;\">\n<li>tar xvzf file-1.0.tar.gz \u2013 to uncompress a gzip tar file (.tgz or .tar.gz)<\/li>\n<li>tar xvjf file-1.0.tar.bz2 \u2013 to uncompress a bzip2 tar file (.tbz or .tar.bz2)<\/li>\n<li>tar xvf file-1.0.tar \u2013 to uncompressed tar file (.tar)<\/li>\n<li>* x = eXtract, this indicated an extraction c = create to create )<\/li>\n<li>* v = verbose (optional) the files with relative locations will be displayed.<\/li>\n<li>* z = gzip-ped; j = bzip2-zipped<\/li>\n<li>* f = from\/to file \u2026 (what is next after the f is the archive file)<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><strong>LOCATING COMMANDS<\/strong><\/p>\n<p style=\"text-align: justify;\">The whereis and apropos utilities help you find a command whose name you have forgotten or whose location you do not know.<br \/>\nThe slocate utility searches for files on the local system.<\/p>\n<p style=\"text-align: justify;\"><strong>which AND whereis: LOCATE A UTILITY<\/strong><\/p>\n<p style=\"text-align: justify;\">When you give Linux command, the shell searches a list of directories for a program with the name and runs the first one it finds.This list of directories is called SEARCH PATH.<\/p>\n<p style=\"text-align: justify;\">The which utility locates utilities (commands) by displaying the full pathname to the file for the utility.The local system may include several commands that have the same name. You can find out which copy of the program the shell will run by using which.<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# which tar<br \/>\n\/bin\/tar<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# which ls<br \/>\n\/bin\/ls<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# which cat<br \/>\n\/bin\/cat<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# which firefox<br \/>\n\/usr\/bin\/firefox<\/p>\n<p style=\"text-align: justify;\">The <strong>which <\/strong>utility can be helpful when a command seems to be working in unexpected ways.By running which utility, you may discover that you are running a nonstandard version of a tool or a different one than you expected.<\/p>\n<p style=\"text-align: justify;\">For example, if tar is not working properly and you find that you are running \/usr\/local\/bin\/tar instead of \/bin\/tar, you might suspect that the version is broken.<\/p>\n<p style=\"text-align: justify;\">The <strong>whereis<\/strong> utility seraches for files related to a utility by looking in standard locations instead of using your search path.<\/p>\n<p style=\"text-align: justify;\">For example, you can find the locations for files related to tar:<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# whereis firefox<br \/>\nfirefox: \/usr\/bin\/firefox \/usr\/share\/man\/man1\/firefox.1.gz<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# whereis tar<br \/>\ntar: \/bin\/tar \/usr\/include\/tar.h \/usr\/share\/man\/man1\/tar.1.gz<\/p>\n<p style=\"text-align: justify;\">In this example whereis finds three references to tar:<\/p>\n<ul style=\"text-align: justify;\">\n<li>-the tar utility file,<\/li>\n<li>-a tar header file,<\/li>\n<li>-the tar man page.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">Under bash you can use the <strong>type<\/strong> builtin to whether a command is a builtin.<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# type cat<br \/>\ncat is \/bin\/cat<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# type firefox<br \/>\nfirefox is \/usr\/bin\/firefox<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# type echo<br \/>\necho is a shell builtin<\/p>\n<h4 style=\"text-align: justify;\"><strong>DIFFERENCE BETWEEN which AND whereis:<\/strong><\/h4>\n<p style=\"text-align: justify;\"><strong>which utility:<\/strong><\/p>\n<p style=\"text-align: justify;\">The which utility looks through the directories in your SEARCH PATH, in order, and locates the program.<br \/>\nIf more thean one program with the specified name in the search path , which displays the name of only the first one(the one you would run).<\/p>\n<p style=\"text-align: justify;\"><strong>whereis utility:<\/strong><\/p>\n<p style=\"text-align: justify;\">The whereis utility looks through a list of standard directories and works independently of your search path.<br \/>\nThe whereis utility is use to locate a binary(excecutable) file, any manual pages, and source code for a program you specify.<br \/>\nThe whereis utility displays all the files it finds.<\/p>\n<p style=\"text-align: justify;\"><strong>apropos: SEARCHES FOR A KEYBOARD<\/strong><\/p>\n<p style=\"text-align: justify;\">When you do not know the name of the command you need to carry out a particular task, you can use a keyboard and the apropos utility to search for it.<\/p>\n<p style=\"text-align: justify;\">The <strong>whatis<\/strong> database has to be set up and regularly maintained with makewhatis for apropos to work.<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# <strong>whatis<\/strong> firefox<br \/>\nfirefox (1) \u2013 a Web browser for X11 derived from the Mozilla browser<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# whatis ls<br \/>\nls (1) \u2013 list directory contents<br \/>\nls (1p) \u2013 list directory contents<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# whatis cat<br \/>\ncat (1) \u2013 concatenate files and print on the standard output<br \/>\ncat (1p) \u2013 concatenate and print files<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# apropos firefox<br \/>\nfirefox (1) \u2013 a Web browser for X11 derived from the Mozilla browser<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# apropos sort<\/p>\n<p style=\"text-align: justify;\">FcFontSetSort (3) \u2013 Add to a font set<br \/>\nFcFontSetSortDestroy (3) \u2013 DEPRECATED destroy a font set<br \/>\nFcFontSort (3) \u2013 Return list of matching fonts<br \/>\nalphasort [scandir] (3) \u2013 scan a directory for matching entries<br \/>\nbsearch (3) \u2013 binary search of a sorted array<br \/>\nbsearch (3p) \u2013 binary search a sorted table<br \/>\nbunzip2 [bzip2] (1) \u2013 a block-sorting file compressor, v1.0.4<br \/>\nbzip2 (1) \u2013 a block-sorting file compressor, v1.0.4<br \/>\ncomm (1) \u2013 compare two sorted files line by line<br \/>\nldap_parse_sort_control (3) \u2013 Decode the information returned from a search operation that used a server-side sort control<br \/>\nldap_sort_entries (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nldap_sort_entries [ldap_sort] (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nldap_sort_entries [ldap_sort_strcasecmp] (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nldap_sort_entries [ldap_sort_values] (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nldap_sort_strcasecmp (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nldap_sort_strcasecmp [ldap_sort] (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nldap_sort_strcasecmp [ldap_sort_entries] (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nldap_sort_strcasecmp [ldap_sort_values] (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nldap_sort_values (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nldap_sort_values [ldap_sort] (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nldap_sort_values [ldap_sort_entries] (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nldap_sort_values [ldap_sort_strcasecmp] (3) \u2013 LDAP sorting routines (deprecated)<br \/>\nlsort (n) \u2013 Sort the elements of a list<br \/>\nqsort (3) \u2013 sorts an array<br \/>\nqsort (3p) \u2013 sort a table of data<br \/>\nsort (1) \u2013 sort lines of text files<br \/>\nsort (1p) \u2013 sort, merge, or sequence check text files<br \/>\nsort (3pm) \u2013 perl pragma to control sort() behaviour<br \/>\ntsort (1) \u2013 perform topological sort<br \/>\ntsort (1p) \u2013 topological sort<br \/>\nversionsort [scandir] (3) \u2013 scan a directory for matching entries<br \/>\n[root@www ~]# apropos who<\/p>\n<p style=\"text-align: justify;\">at.allow [at] (5) \u2013 determine who can submit jobs via at or batch<br \/>\nat.deny [at] (5) \u2013 determine who can submit jobs via at or batch<br \/>\ndoveadm-who (1) \u2013 Show who is logged in to the Dovecot server<br \/>\nw (1) \u2013 Show who is logged on and what they are doing<br \/>\nwho (1) \u2013 show who is logged on<br \/>\nwho (1p) \u2013 display who is on the system<br \/>\nwhoami (1) \u2013 print effective userid<\/p>\n<h4 style=\"text-align: justify;\"><strong>locate: SEARCHES FOR A FILE<\/strong><\/h4>\n<p style=\"text-align: justify;\">[root@www ~]# locate hello<\/p>\n<p style=\"text-align: justify;\">\/opt\/libreoffice3.5\/program\/python-core-2.6.1\/lib\/__phello__.foo.py<br \/>\n\/opt\/libreoffice3.5\/share\/Scripts\/beanshell\/HelloWorld\/helloworld.bsh<br \/>\n\/opt\/libreoffice3.5\/share\/Scripts\/javascript\/HelloWorld\/helloworld.js<br \/>\n\/usr\/lib\/vmware-installer\/2.0\/python\/lib\/__phello__.foo.py<br \/>\n\/usr\/lib\/vmware-installer\/2.0\/python\/lib\/__phello__.foo.pyc<br \/>\n\/usr\/lib64\/python2.6\/__phello__.foo.py<br \/>\n\/usr\/lib64\/python2.6\/__phello__.foo.pyc<br \/>\n\/usr\/lib64\/python2.6\/__phello__.foo.pyo<br \/>\n\/usr\/share\/doc\/cmake-2.6.4\/Example\/Hello\/hello.cxx<br \/>\n\/usr\/share\/doc\/cmake-2.6.4\/Example\/Hello\/hello.h<br \/>\n\/usr\/share\/doc\/gnome-python2-bonobo-2.28.0\/bonoboui\/hello.py<br \/>\n\/usr\/share\/doc\/numpy-1.3.0\/docs-f2py\/hello.f<br \/>\n\/usr\/share\/doc\/pygtk2-2.16.0\/examples\/simple\/hello.py<br \/>\n\/usr\/share\/doc\/python-genshi-0.5.1\/examples\/webpy\/hello.html<br \/>\n\/usr\/share\/doc\/python-genshi-0.5.1\/examples\/webpy\/hello.py<br \/>\n\/usr\/share\/doc\/python-qpid-0.7.946106\/examples\/api\/hello<br \/>\n\/usr\/share\/doc\/python-qpid-0.7.946106\/examples\/api\/hello_xml<br \/>\n\/usr\/share\/doc\/python-twisted-web-8.2.0\/examples\/hello.rpy.py<br \/>\n\/usr\/share\/dstat\/dstat_helloworld.py<br \/>\n\/usr\/share\/dstat\/dstat_helloworld.pyc<br \/>\n\/usr\/share\/tk8.5\/demos\/hello<br \/>\n\/var\/www\/html\/wp-content\/plugins\/hello.php<\/p>\n<p style=\"text-align: justify;\">(hello is a filename)<\/p>\n<h3 style=\"text-align: justify;\"><strong>OBTAINING USER AND SYSTEM INFORMATION<\/strong><\/h3>\n<p style=\"text-align: justify;\"><strong>who: LISTS USERS ON THE SCREEN<\/strong><\/p>\n<p style=\"text-align: justify;\">The who utility displays a list of users who are logged in.<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# who<\/p>\n<p style=\"text-align: justify;\">username terminal Date and Time<\/p>\n<p style=\"text-align: justify;\">root tty1 2013-01-23 08:44 (:0)<br \/>\nroot pts\/0 2013-01-23 08:52 (:0.0)<br \/>\n[root@www ~]# who<\/p>\n<p style=\"text-align: justify;\">username terminal Date and Time<\/p>\n<p style=\"text-align: justify;\">root tty2 2013-01-23 09:30<br \/>\nroot tty1 2013-01-23 08:44 (:0)<br \/>\nroot pts\/0 2013-01-23 08:52 (:0.0)<br \/>\n[root@www ~]# who<\/p>\n<p style=\"text-align: justify;\">username terminal Date and Time<\/p>\n<p style=\"text-align: justify;\">mc712 tty3 2013-01-23 09:30<br \/>\nroot tty2 2013-01-23 09:30<br \/>\nroot tty1 2013-01-23 08:44 (:0)<br \/>\nroot pts\/0 2013-01-23 08:52 (:0.0)<br \/>\n<strong>DIFFERENCE BETWEEN whoami and who am i :<\/strong><br \/>\n<strong>who am i<\/strong>: If you find which terminal you are using or what time you logged in,you can use the command whoami.<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# who am i<br \/>\nroot pts\/0 2013-01-23 08:52 (:0.0)<\/p>\n<p style=\"text-align: justify;\">[mc712@www ~]$ who am i<br \/>\nroot pts\/0 2013-01-23 08:52 (:0.0)<\/p>\n<p style=\"text-align: justify;\"><strong>whoami<\/strong>: Display the name of current login user.<\/p>\n<p style=\"text-align: justify;\">[mc712@www ~]$ whoami<br \/>\nmc712<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# whoami<br \/>\nroot<\/p>\n<h4 style=\"text-align: justify;\"><strong>finger: LISTS USERS ON THE SYSTEM<\/strong><\/h4>\n<p style=\"text-align: justify;\">On systems whereis secuity is a concern, the system administrator may disable finger. This utility can give information that can help a malcious user break into the system.<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# finger<\/p>\n<p style=\"text-align: justify;\">Login Name Tty Idle Login Time Office Office Phone<br \/>\nroot root tty2 18 Jan 23 09:30<br \/>\nroot root tty1 1:12 Jan 23 08:44 (:0)<br \/>\nroot root pts\/0 Jan 23 08:52 (:0.0)<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# pinky<br \/>\nLogin Name TTY Idle When Where<br \/>\nroot root tty2 00:21 2013-01-23 09:30<br \/>\nroot root tty1 01:15 2013-01-23 08:44 :0<br \/>\nroot root pts\/0 2013-01-23 08:52 :0.0<\/p>\n<p style=\"text-align: justify;\"><strong>lchfn: CHANGING FINGER INFORMATION.<\/strong><br \/>\n[root@www ~]# lchfn<\/p>\n<p style=\"text-align: justify;\">Changing finger information for root.<br \/>\nFull Name [root]: Manish Chauhan<br \/>\nOffice: Jalandhar<br \/>\nOffice Phone: 987654321<br \/>\nHome Phone: 0181-2222222<br \/>\nFinger information changed.<br \/>\n[root@www ~]# finger<br \/>\nLogin Name Tty Idle Login Time Office Office Phone<br \/>\nroot Manish Chauhan tty2 23 Jan 23 09:30 Jalandhar 987654321<br \/>\nroot Manish Chauhan tty1 1:17 Jan 23 08:44 (:0)<br \/>\nroot Manish Chauhan pts\/0 Jan 23 08:52 (:0.0)<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# finger mc712<br \/>\nLogin: mc712 Name: mc712<br \/>\nDirectory: \/home\/mc712 Shell: \/bin\/bash<br \/>\nLast login Wed Jan 23 09:30 (IST) on tty3<br \/>\nMail last read Tue Dec 18 11:24 2012 (IST)<br \/>\nNo Plan.<br \/>\n<strong>w: LIST USERS ON THE SYSTEM<\/strong><\/p>\n<p style=\"text-align: justify;\">The w utility displays the list of uses who are logged in.<br \/>\n[root@www ~]# w<\/p>\n<p style=\"text-align: justify;\">10:02:41 up 1:20, 3 users, load average: 0.03, 0.05, 0.11<\/p>\n<p style=\"text-align: justify;\">USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT<br \/>\nroot tty2 \u2013 09:30 26:04 0.01s 0.01s -bash<br \/>\nroot tty1 :0 08:44 1:20m 1:17 1:17 \/usr\/bin\/Xorg :0 -nr -verbose -auth<br \/>\nroot pts\/0 :0.0 08:52 0.00s 0.29s 0.11s w<\/p>\n<p style=\"text-align: justify;\">The first line displays the time of the day, the period of time the computer has been running(in days, hours, and minutes), the number of users logged in, and the load average(how busy the system is).<br \/>\nThe three load average numbers represent the number of jobs waiting to run, averaged over the past minutes.<\/p>\n<p style=\"text-align: justify;\">Use the <strong>uptime<\/strong> utility to display just this line<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# uptime<br \/>\n10:08:20 up 1:26, 3 users, load average: 0.00, 0.02, 0.07<\/p>\n<p style=\"text-align: justify;\"><b>COMPARISON<\/b><strong>\u00a0OF W, WHO, AND FINGER<\/strong><\/p>\n<p style=\"text-align: justify;\"><strong> Information Displayed<\/strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<strong>w \u00a0who \u00a0finger<\/strong><\/p>\n<ul style=\"text-align: justify;\">\n<li>1. User login name \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0X \u00a0 X \u00a0 \u00a0X<\/li>\n<li>2. Terminal-line identification(tty) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0X \u00a0 X \u00a0 \u00a0X<\/li>\n<li>3. Login day and time \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0X \u00a0 \u00a0 \u00a0 \u00a0 X<\/li>\n<li>4. Login Date and Time \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0X<\/li>\n<li>5. Idls Time \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0X \u00a0 \u00a0 \u00a0 \u00a0 X<\/li>\n<li>6. What Program the user is excecuting \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0X<\/li>\n<li>7. Where the user logged in from \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 X<\/li>\n<li>8. CPU time used X<\/li>\n<li>9. Full name (or other information from \/etc\/passwd) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 X<\/li>\n<li>10.User-supplied vanity information \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 X<\/li>\n<li>11.System uptime and load average \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 X<\/li>\n<\/ul>\n<h4 style=\"text-align: justify;\"><strong>COMMUNICATION WITH OTHER USERS<\/strong><\/h4>\n<p style=\"text-align: justify;\"><strong>write: SENDS A MESSAGE<\/strong><\/p>\n<p style=\"text-align: justify;\">The write utility sends a message to another user who is logged in.<br \/>\nWhen you and another user use write command to send messages to each other, you establish two-way communication.<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# write mc712<br \/>\nHello mc712. How are you ? o<\/p>\n<p style=\"text-align: justify;\">press (ctrl+d), o means over<br \/>\nGoto user terminal<\/p>\n<p style=\"text-align: justify;\"><em>[mc712@www ~]$<\/em><br \/>\n<em> Message from <a href=\"mailto:root@www.mc712.com\">root@www.mc712.com<\/a> on pts\/0 at 10:42 \u2026<\/em><br \/>\n<em> Hello mc712. How are you ? o<\/em><br \/>\n<em> EOF<\/em><\/p>\n<p style=\"text-align: justify;\">(EOF-END OF FILE)<\/p>\n<h4 style=\"text-align: justify;\"><strong>mesg: DENIES OR ACCEPT MESSAGES<\/strong><\/h4>\n<p style=\"text-align: justify;\">Give the following command when you do not wish to receive messages from another user:<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# mesg n<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# write mc712<br \/>\nwrite: you have write permission turned off.<br \/>\nGoto user terminal<\/p>\n<p style=\"text-align: justify;\">[mc712@www ~]$ write mc712<br \/>\nwrite: root has message disable<br \/>\nYou can allow messages again by entring <strong>mesg y.<\/strong><\/p>\n<p style=\"text-align: justify;\">[root@www ~]# mesg y<\/p>\n<p style=\"text-align: justify;\">Hence mesg permits or denies messages sent by write.<\/p>\n<h4 style=\"text-align: justify;\"><strong>wc: WORD COUNT<\/strong><\/h4>\n<p style=\"text-align: justify;\">This command is use to count character, words and lines from the file.<br \/>\n[root@www www]# cat file1<br \/>\nHello<br \/>\nHow are you ?<br \/>\nI am fine<\/p>\n<p style=\"text-align: justify;\">[root@www www]# wc file1<\/p>\n<p style=\"text-align: justify;\">lines words characters<br \/>\n3 8 32 file1<br \/>\n<strong>tr: Translate or Transliterate<\/strong><\/p>\n<p style=\"text-align: justify;\">The tr utility copies the given input to produced the output with substitution or deletion of selected characters.<br \/>\nIt takes as parameters two sets of characters, and replaces occurrences of the characters in the first set with the corresponding elements from the other set i.e. it is used to translate characters.<\/p>\n<p style=\"text-align: justify;\">[root@www www]# tr \u2018a-z\u2019 \u2018A-Z\u2019<br \/>\nmanish chauhan \u2013 input<br \/>\nMANISH CHAUHAN \u2013 output<br \/>\n<strong>mount<\/strong>: This command is use to mount the usb, cd or any other device.<\/p>\n<p style=\"text-align: justify;\">[root@www ~]# mount \/dev\/cdrom \/root\/Desktop\/mc712\/<\/p>\n<p style=\"text-align: justify;\"><strong>umount<\/strong>: This command is use to unmout the cd, Dvd or any other device.<br \/>\n[root@www ~]# umount\/dev\/cdrom<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When Linus Torvald introduced Linux and For a long time thereafter, Linux did not have a graphical user interface: It run on character-based terminals only. All the tools ran from a command line.Today the Linux GUI is important, but many people-especially system Administrators-run many command line programs.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-95","post","type-post","status-publish","format-standard","hentry","category-redhat-linux-operating-system"],"_links":{"self":[{"href":"http:\/\/www.mandcgroup.in\/blog\/wp-json\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.mandcgroup.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.mandcgroup.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.mandcgroup.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.mandcgroup.in\/blog\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":3,"href":"http:\/\/www.mandcgroup.in\/blog\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":100,"href":"http:\/\/www.mandcgroup.in\/blog\/wp-json\/wp\/v2\/posts\/95\/revisions\/100"}],"wp:attachment":[{"href":"http:\/\/www.mandcgroup.in\/blog\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.mandcgroup.in\/blog\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.mandcgroup.in\/blog\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}