{"id":118,"date":"2018-07-25T14:07:53","date_gmt":"2018-07-25T10:07:53","guid":{"rendered":"http:\/\/kidds.co.za\/?p=118"},"modified":"2018-07-25T14:43:04","modified_gmt":"2018-07-25T10:43:04","slug":"20-should-know-linux-command","status":"publish","type":"post","link":"https:\/\/kidds.co.za\/index.php\/2018\/07\/25\/20-should-know-linux-command\/","title":{"rendered":"20 should know linux commands"},"content":{"rendered":"<p><a href=\"https:\/\/www.tecmint.com\/20-advanced-commands-for-middle-level-linux-users\/\">Original Article tecmint.com<\/a><\/p>\n<h3>21. Command: Find<\/h3>\n<p>Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.<\/p>\n<pre>root@tecmint:~# find -name *.sh \r\n.\/Desktop\/load.sh \r\n.\/Desktop\/test.sh \r\n.\/Desktop\/shutdown.sh \r\n.\/Binary\/firefox\/run-mozilla.sh \r\n.\/Downloads\/kdewebdev-3.5.8\/quanta\/scripts\/externalpreview.sh \r\n.\/Downloads\/kdewebdev-3.5.8\/admin\/doxygen.sh \r\n.\/Downloads\/kdewebdev-3.5.8\/admin\/cvs.sh \r\n.\/Downloads\/kdewebdev-3.5.8\/admin\/ltmain.sh \r\n.\/Downloads\/wheezy-nv-install.sh<\/pre>\n<p><strong>Note:<\/strong>\u00a0The `<strong>-name<\/strong>\u2018 option makes the search case sensitive. You can use the `<strong>-iname<\/strong>\u2018 option to find something regardless of case. (<strong>*<\/strong>\u00a0is a wildcard and searches all the file having extension \u2018<strong>.sh<\/strong>\u2018 you can use filename or a part of file name to customise the output).<\/p>\n<pre>root@tecmint:~# find -iname *.SH ( find -iname *.Sh \/  find -iname *.sH)\r\n.\/Desktop\/load.sh \r\n.\/Desktop\/test.sh \r\n.\/Desktop\/shutdown.sh \r\n.\/Binary\/firefox\/run-mozilla.sh \r\n.\/Downloads\/kdewebdev-3.5.8\/quanta\/scripts\/externalpreview.sh \r\n.\/Downloads\/kdewebdev-3.5.8\/admin\/doxygen.sh \r\n.\/Downloads\/kdewebdev-3.5.8\/admin\/cvs.sh \r\n.\/Downloads\/kdewebdev-3.5.8\/admin\/ltmain.sh \r\n.\/Downloads\/wheezy-nv-install.sh<\/pre>\n<pre>root@tecmint:~# find -name *.tar.gz \r\n\/var\/www\/modules\/update\/tests\/aaa_update_test.tar.gz \r\n.\/var\/cache\/flashplugin-nonfree\/install_flash_player_11_linux.i386.tar.gz \r\n.\/home\/server\/Downloads\/drupal-7.22.tar.gz \r\n.\/home\/server\/Downloads\/smtp-7.x-1.0.tar.gz \r\n.\/home\/server\/Downloads\/noreqnewpass-7.x-1.2.tar.gz \r\n.\/usr\/share\/gettext\/archive.git.tar.gz \r\n.\/usr\/share\/doc\/apg\/php.tar.gz \r\n.\/usr\/share\/doc\/festival\/examples\/speech_pm_1.0.tar.gz \r\n.\/usr\/share\/doc\/argyll\/examples\/spyder2.tar.gz \r\n.\/usr\/share\/usb_modeswitch\/configPack.tar.gz<\/pre>\n<p><strong>Note<\/strong>: The above command searches for all the file having extension \u2018<strong>tar.gz<\/strong>\u2018 in root directory and all the sub-directories including mounted devices.<\/p>\n<p><center><\/center>Read more examples of Linux \u2018<strong>find<\/strong>\u2018 command at\u00a0<a href=\"https:\/\/www.tecmint.com\/35-practical-examples-of-linux-find-command\/\" target=\"_blank\" rel=\"noopener\">35 Find Command Examples in Linux<\/a><\/p>\n<h3>22. Command: grep<\/h3>\n<p>The \u2018<strong>grep<\/strong>\u2018 command searches the given file for lines containing a match to the given strings or words. Search \u2018<strong>\/etc\/passwd<\/strong>\u2018 for \u2018<strong>tecmint<\/strong>\u2018 user.<\/p>\n<pre>root@tecmint:~# grep tecmint \/etc\/passwd \r\ntecmint:x:1000:1000:Tecmint,,,:\/home\/tecmint:\/bin\/bash<\/pre>\n<p>Ignore word case and all other combination with \u2018<strong>-i<\/strong>\u2018 option.<\/p>\n<pre>root@tecmint:~# grep -i TECMINT \/etc\/passwd \r\ntecmint:x:1000:1000:Tecmint,,,:\/home\/tecmint:\/bin\/bash<\/pre>\n<p>Search recursively (<strong>-r<\/strong>)\u00a0<strong>i.e.<\/strong>\u00a0read all files under each directory for a string \u201c<strong>127.0.0.1<\/strong>\u201c.<\/p>\n<pre>root@tecmint:~# grep -r \"127.0.0.1\" \/etc\/ \r\n\/etc\/vlc\/lua\/http\/.hosts:127.0.0.1\r\n\/etc\/speech-dispatcher\/modules\/ivona.conf:#IvonaServerHost \"127.0.0.1\"\r\n\/etc\/mysql\/my.cnf:bind-address\t\t= 127.0.0.1\r\n\/etc\/apache2\/mods-available\/status.conf:    Allow from 127.0.0.1 ::1\r\n\/etc\/apache2\/mods-available\/ldap.conf:    Allow from 127.0.0.1 ::1\r\n\/etc\/apache2\/mods-available\/info.conf:    Allow from 127.0.0.1 ::1\r\n\/etc\/apache2\/mods-available\/proxy_balancer.conf:#    Allow from 127.0.0.1 ::1\r\n\/etc\/security\/access.conf:#+ : root : 127.0.0.1\r\n\/etc\/dhcp\/dhclient.conf:#prepend domain-name-servers 127.0.0.1;\r\n\/etc\/dhcp\/dhclient.conf:#  option domain-name-servers 127.0.0.1;\r\n\/etc\/init\/network-interface.conf:\tifconfig lo 127.0.0.1 up || true\r\n\/etc\/java-6-openjdk\/net.properties:# localhost &amp; 127.0.0.1).\r\n\/etc\/java-6-openjdk\/net.properties:# http.nonProxyHosts=localhost|127.0.0.1\r\n\/etc\/java-6-openjdk\/net.properties:# localhost &amp; 127.0.0.1).\r\n\/etc\/java-6-openjdk\/net.properties:# ftp.nonProxyHosts=localhost|127.0.0.1\r\n\/etc\/hosts:127.0.0.1\tlocalhost<\/pre>\n<p><strong>Note<\/strong>: You can use these following options along with\u00a0<strong>grep<\/strong>.<\/p>\n<ol>\n<li><strong>-w<\/strong>\u00a0for word (egrep -w \u2018<strong>word1<\/strong>|<strong>word2<\/strong>\u2018 \/path\/to\/file).<\/li>\n<li><strong>-c<\/strong>\u00a0for count (i.e., total number of times the pattern matched) (grep -c \u2018<strong>word<\/strong>\u2018 \/path\/to\/file).<\/li>\n<li><strong>\u2013color<\/strong>\u00a0for coloured output (grep\u00a0<strong>\u2013color<\/strong>\u00a0server \/etc\/passwd).<\/li>\n<\/ol>\n<h3>23. Command: man<\/h3>\n<p>The \u2018<strong>man<\/strong>\u2018 is the system\u2019s manual pager. Man provides online documentation for all the possible options with a command and its usages. Almost all the command comes with their corresponding manual pages. For example,<\/p>\n<pre>root@tecmint:~# man man\r\nMAN(1)                                                               Manual pager utils                                                              MAN(1)\r\nNAME\r\nman - an interface to the on-line reference manuals\r\nSYNOPSIS\r\nman  [-C  file]  [-d]  [-D]  [--warnings[=warnings]]  [-R  encoding]  [-L  locale]  [-m  system[,...]]  [-M  path]  [-S list] [-e extension] [-i|-I]\r\n[--regex|--wildcard] [--names-only] [-a] [-u] [--no-subpages] [-P pager] [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justification]  [-p\r\nstring] [-t] [-T[device]] [-H[browser]] [-X[dpi]] [-Z] [[section] page ...] ...\r\nman -k [apropos options] regexp ...\r\nman -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...\r\nman -f [whatis options] page ...\r\nman -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t] [-T[device]]\r\n[-H[browser]] [-X[dpi]] [-Z] file ...\r\nman -w|-W [-C file] [-d] [-D] page ...\r\nman -c [-C file] [-d] [-D] page ...\r\nman [-hV]<\/pre>\n<p>Manual page for man page itself, similarly \u2018<strong>man cat<\/strong>\u2018 (Manual page for\u00a0<a href=\"https:\/\/www.tecmint.com\/13-basic-cat-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">cat command<\/a>) and \u2018<strong>man ls<\/strong>\u2018 (Manual page for\u00a0<a href=\"https:\/\/www.tecmint.com\/15-basic-ls-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">command ls<\/a>).<\/p>\n<p><strong>Note<\/strong>: man page is intended for command reference and learning.<\/p>\n<h3>24. Command: ps<\/h3>\n<p><strong>ps<\/strong>\u00a0(<strong>Process<\/strong>) gives the status of running processes with a unique\u00a0<strong>Id<\/strong>\u00a0called\u00a0<strong>PID<\/strong>.<\/p>\n<pre>root@tecmint:~# ps\r\nPID TTY          TIME CMD\r\n4170 pts\/1    00:00:00 bash\r\n9628 pts\/1    00:00:00 ps<\/pre>\n<p>To list status of all the processes along with process\u00a0<strong>id<\/strong>\u00a0and\u00a0<strong>PID<\/strong>, use option \u2018<strong>-A<\/strong>\u2018.<\/p>\n<pre>root@tecmint:~# ps -A\r\nPID TTY          TIME CMD\r\n1 ?        00:00:01 init\r\n2 ?        00:00:00 kthreadd\r\n3 ?        00:00:01 ksoftirqd\/0\r\n5 ?        00:00:00 kworker\/0:0H\r\n7 ?        00:00:00 kworker\/u:0H\r\n8 ?        00:00:00 migration\/0\r\n9 ?        00:00:00 rcu_bh\r\n....<\/pre>\n<p><strong>Note<\/strong>: This command is very useful when you want to know which processes are running or may need\u00a0<strong>PID<\/strong>sometimes, for process to be killed. You can use it with \u2018<strong>grep<\/strong>\u2018 command to find customised output. For example,<\/p>\n<pre>root@tecmint:~# ps -A | grep -i ssh\r\n1500 ?        00:09:58 sshd\r\n4317 ?        00:00:00 sshd<\/pre>\n<p>Here \u2018<strong>ps<\/strong>\u2018 is pipelined with \u2018<strong>grep<\/strong>\u2018 command to find customised and relevant output of our need.<\/p>\n<h3>25. Command: kill<\/h3>\n<p>OK, you might have understood what this command is for, from the name of the command. This command is used to kill process which is not relevant now or is not responding. It is very useful command, rather a very very useful command. You might be familiar with frequent windows restarting because of the fact that most of the time a running process can\u2019t be killed, and if killed it needs windows to get restart so that changes could be taken into effect but in the world of Linux, there is no such things. Here you can kill a process and start it without restarting the whole system.<\/p>\n<p>You need a process\u2019s pid (ps) to kill it.<\/p>\n<p>Let suppose you want to kill program \u2018<strong>apache2<\/strong>\u2018 that might not be responding. Run \u2018<strong>ps -A<\/strong>\u2018 along with\u00a0<strong>grep<\/strong>command.<\/p>\n<pre>root@tecmint:~# ps -A | grep -i apache2\r\n1285 ?        00:00:00 apache2<\/pre>\n<p>Find process \u2018<strong>apache2<\/strong>\u2018, note its\u00a0<strong>pid<\/strong>\u00a0and\u00a0<strong>kill<\/strong>\u00a0it. For example, in my case \u2018<strong>apache2<\/strong>\u2018 pid is \u2018<strong>1285<\/strong>\u2018.<\/p>\n<pre>root@tecmint:~# kill 1285 (to kill the process apache2)<\/pre>\n<p><strong>Note<\/strong>: Every time you re-run a process or start a system, a new\u00a0<strong>pid<\/strong>\u00a0is generated for each process and you can know about the current running processes and its\u00a0<strong>pid<\/strong>\u00a0using command \u2018<strong>ps<\/strong>\u2018.<\/p>\n<p>Another way to kill the same process is.<\/p>\n<pre>root@tecmint:~# pkill apache2<\/pre>\n<p><strong>Note<\/strong>: Kill requires\u00a0<strong>job id<\/strong>\u00a0\/\u00a0<strong>process id<\/strong>\u00a0for sending signals, where as in\u00a0<strong>pkill,\u00a0<\/strong>you have an option of using pattern, specifying process owner, etc.<\/p>\n<h3>26. Command: whereis<\/h3>\n<p>The \u2018<strong>whereis<\/strong>\u2018 command is used to locate the\u00a0<strong>Binary<\/strong>,\u00a0<strong>Sources<\/strong>\u00a0and\u00a0<strong>Manual Pages<\/strong>\u00a0of the command. For example, to locate the\u00a0<strong>Binary<\/strong>,\u00a0<strong>Sources<\/strong>\u00a0and\u00a0<strong>Manual Pages<\/strong>\u00a0of the command \u2018<strong>ls<\/strong>\u2018 and \u2018<strong>kill<\/strong>\u2018.<\/p>\n<pre>root@tecmint:~# whereis ls \r\nls: \/bin\/ls \/usr\/share\/man\/man1\/ls.1.gz<\/pre>\n<pre>root@tecmint:~# whereis kill\r\nkill: \/bin\/kill \/usr\/share\/man\/man2\/kill.2.gz \/usr\/share\/man\/man1\/kill.1.gz<\/pre>\n<p><strong>Note<\/strong>: This is useful to know where the binaries are installed for manual editing sometimes.<\/p>\n<h3>27. Command: service<\/h3>\n<p>The \u2018<strong>service<\/strong>\u2018 command controls the\u00a0<strong>Starting<\/strong>,\u00a0<strong>Stopping<\/strong>\u00a0or\u00a0<strong>Restarting<\/strong>\u00a0of a \u2018<strong>service<\/strong>\u2018. This command make it possible to\u00a0<strong>start<\/strong>,\u00a0<strong>restart<\/strong>\u00a0or\u00a0<strong>stop<\/strong>\u00a0a service without restarting the system, for the changes to be taken into effect.<\/p>\n<h4>Startting an apache2 server on Ubuntu<\/h4>\n<pre>root@tecmint:~# service apache2 start\r\n* Starting web server apache2                                                                                                                                 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName\r\nhttpd (pid 1285) already running\t\t\t\t\t\t[ OK ]<\/pre>\n<h4>Restarting a apache2 server on Ubuntu<\/h4>\n<pre>root@tecmint:~# service apache2 restart\r\n* Restarting web server apache2                                                                                                                               apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName\r\n... waiting .apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName  [ OK ]<\/pre>\n<h4>Stopping a apache2 server on Ubuntu<\/h4>\n<pre>root@tecmint:~# service apache2 stop\r\n* Stopping web server apache2                                                                                                                                 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName\r\n... waiting                                                           \t\t[ OK ]<\/pre>\n<p><strong>Note<\/strong>: All the process script lies in \u2018<strong>\/etc\/init.d<\/strong>\u2018, and the path might needs to be included on certain system, i.e., in spite of running \u201c<strong>service apache2 start<\/strong>\u201d you would be asked to run \u201c<strong>\/etc\/init.d\/apache2 start<\/strong>\u201d.<\/p>\n<h3>28. Command: alias<\/h3>\n<p><strong>alias<\/strong>\u00a0is a built in shell command that lets you assign name for a long command or frequently used command.<\/p>\n<p>I uses \u2018<strong>ls -l<\/strong>\u2018 command frequently, which includes\u00a0<strong>5<\/strong>\u00a0characters including space. Hence I created an alias for this to \u2018<strong>l<\/strong>\u2018.<\/p>\n<pre>root@tecmint:~# alias l='ls -l'<\/pre>\n<p>check if it works or not.<\/p>\n<pre>root@tecmint:~# l\r\ntotal 36 \r\ndrwxr-xr-x 3 tecmint tecmint 4096 May 10 11:14 Binary \r\ndrwxr-xr-x 3 tecmint tecmint 4096 May 21 11:21 Desktop \r\ndrwxr-xr-x 2 tecmint tecmint 4096 May 21 15:23 Documents \r\ndrwxr-xr-x 8 tecmint tecmint 4096 May 20 14:56 Downloads \r\ndrwxr-xr-x 2 tecmint tecmint 4096 May  7 16:58 Music \r\ndrwxr-xr-x 2 tecmint tecmint 4096 May 20 16:17 Pictures \r\ndrwxr-xr-x 2 tecmint tecmint 4096 May  7 16:58 Public \r\ndrwxr-xr-x 2 tecmint tecmint 4096 May  7 16:58 Templates \r\ndrwxr-xr-x 2 tecmint tecmint 4096 May  7 16:58 Videos<\/pre>\n<p>To remove alias \u2018<strong>l<\/strong>\u2018, use the following \u2018<strong>unalias<\/strong>\u2018 command.<\/p>\n<pre>root@tecmint:~# unalias l<\/pre>\n<p>check, if \u2018<strong>l<\/strong>\u2018 still is alias or not.<\/p>\n<pre>root@tecmint:~# l\r\nbash: l: command not found<\/pre>\n<p>Making a little fun out of this command. Make alias of certain important command to some other important command.<\/p>\n<pre>alias cd='ls -l' (set alias of ls -l to cd)\r\nalias su='pwd' (set alias of pwd to su)\r\n....\r\n(You can create your own)\r\n....<\/pre>\n<p>Now when your friend types \u2018<strong>cd<\/strong>\u2018, just think how funny it would be when he gets directory listing and not directory changing. And when he tries to be \u2018<strong>su<\/strong>\u2018 the all he gets is the location of working directory. You can remove the alias later using command \u2018<strong>unalias<\/strong>\u2018 as explained above.<\/p>\n<h3>29. Command: df<\/h3>\n<p>Report disk usages of file system. Useful for user as well as System Administrator to keep track of their disk usages. \u2018<strong>df<\/strong>\u2018 works by examining directory entries, which generally are updated only when a file is closed.<\/p>\n<pre>root@tecmint:~# df\r\nFilesystem     1K-blocks    Used Available Use% Mounted on\r\n\/dev\/sda1       47929224 7811908  37675948  18% \/\r\nnone                   4       0         4   0% \/sys\/fs\/cgroup\r\nudev             1005916       4   1005912   1% \/dev\r\ntmpfs             202824     816    202008   1% \/run\r\nnone                5120       0      5120   0% \/run\/lock\r\nnone             1014120     628   1013492   1% \/run\/shm\r\nnone              102400      44    102356   1% \/run\/user\r\n\/dev\/sda5         184307   79852     94727  46% \/boot\r\n\/dev\/sda7       95989516   61104  91045676   1% \/data\r\n\/dev\/sda8       91953192   57032  87218528   1% \/personal<\/pre>\n<p>For more examples of \u2018<strong>df<\/strong>\u2018 command, read the article\u00a0<a href=\"https:\/\/www.tecmint.com\/how-to-check-disk-space-in-linux\/\" target=\"_blank\" rel=\"noopener\">12 df Command Examples in Linux<\/a>.<\/p>\n<h3>30. Command: du<\/h3>\n<p>Estimate file space usage. Output the summary of disk usages by ever file hierarchically, i.e., in recursive manner.<\/p>\n<pre>root@tecmint:~# du\r\n8       .\/Daily Pics\/wp-polls\/images\/default_gradient\r\n8       .\/Daily Pics\/wp-polls\/images\/default\r\n32      .\/Daily Pics\/wp-polls\/images\r\n8       .\/Daily Pics\/wp-polls\/tinymce\/plugins\/polls\/langs\r\n8       .\/Daily Pics\/wp-polls\/tinymce\/plugins\/polls\/img\r\n28      .\/Daily Pics\/wp-polls\/tinymce\/plugins\/polls\r\n32      .\/Daily Pics\/wp-polls\/tinymce\/plugins\r\n36      .\/Daily Pics\/wp-polls\/tinymce\r\n580     .\/Daily Pics\/wp-polls\r\n1456    .\/Daily Pics\r\n36      .\/Plugins\/wordpress-author-box\r\n16180   .\/Plugins\r\n12      .\/May Articles 2013\/Xtreme Download Manager\r\n4632    .\/May Articles 2013\/XCache<\/pre>\n<p><strong>Note<\/strong>: \u2018<strong>df<\/strong>\u2018 only reports usage statistics on file systems, while \u2018<strong>du<\/strong>\u2018, on the other hand, measures directory contents. For more \u2018<strong>du<\/strong>\u2018 command examples and usage, read\u00a0<a href=\"https:\/\/www.tecmint.com\/check-linux-disk-usage-of-files-and-directories\/\" target=\"_blank\" rel=\"noopener\">10 du (Disk Usage) Commands<\/a>.<\/p>\n<h3>31. Command: rm<\/h3>\n<p>The command \u2018<strong>rm<\/strong>\u2018 stands for remove.\u00a0<strong>rm<\/strong>\u00a0is used to remove files (s) and directories.<\/p>\n<h4>Removing a directory<\/h4>\n<pre>root@tecmint:~# rm PassportApplicationForm_Main_English_V1.0\r\nrm: cannot remove `PassportApplicationForm_Main_English_V1.0': Is a directory<\/pre>\n<p>The directory can\u2019t be removed simply by \u2018<strong>rm<\/strong>\u2018 command, you have to use \u2018<strong>-rf<\/strong>\u2018 switch along with \u2018<strong>rm<\/strong>\u2018.<\/p>\n<pre>root@tecmint:~# rm -rf PassportApplicationForm_Main_English_V1.0<\/pre>\n<p><strong>Warning<\/strong>: \u201c<strong>rm -rf<\/strong>\u201d command is a destructive command if accidently you make it to the wrong directory. Once you \u2018<strong>rm -rf<\/strong>\u2018 a directory all the files and the directory itself is lost forever, all of a sudden. Use it with caution.<\/p>\n<h3>32. Command: echo<\/h3>\n<p><strong>echo<\/strong>\u00a0as the name suggest echoes a text on the standard output. It has nothing to do with shell, nor does shell reads the output of echo command. However in an interactive script, echo passes the message to the user through terminal. It is one of the command that is commonly used in scripting, interactive scripting.<\/p>\n<pre>root@tecmint:~# echo \"Tecmint.com is a very good website\" \r\nTecmint.com is a very good website<\/pre>\n<h5>creating a small interactive script<\/h5>\n<p>1. create a file, named \u2018<strong>interactive_shell.sh<\/strong>\u2018 on desktop. (Remember \u2018<strong>.sh<\/strong>\u2018 extension is must).<br \/>\n2. copy and paste the below script, exactly same, as below.<\/p>\n<pre>#!\/bin\/bash \r\necho \"Please enter your name:\" \r\nread name \r\necho \"Welcome to Linux $name\"<\/pre>\n<p>Next, set execute permission and run the script.<\/p>\n<pre>root@tecmint:~# chmod 777 interactive_shell.sh<\/pre>\n<pre>root@tecmint:~# .\/interactive_shell.sh\r\nPlease enter your name:\r\nRavi Saive\r\nWelcome to Linux Ravi Saive<\/pre>\n<p><strong>Note<\/strong>: \u2018<strong>#!\/bin\/bash<\/strong>\u2018 tells the shell that it is an script an it is always a good idea to include it at the top of script. \u2018<strong>read<\/strong>\u2018 reads the given input.<\/p>\n<h3>33. Command: passwd<\/h3>\n<p>This is an important command that is useful for changing own password in terminal. Obviously you need to know your current passowrd for Security reason.<\/p>\n<pre>root@tecmint:~# passwd \r\nChanging password for tecmint. \r\n(current) UNIX password: ******** \r\nEnter new UNIX password: ********\r\nRetype new UNIX password: ********\r\nPassword unchanged   [Here was passowrd remians unchanged, i.e., new password=old password]\r\nEnter new UNIX password: #####\r\nRetype new UNIX password:#####<\/pre>\n<h3>34. Command: lpr<\/h3>\n<p>This command print files named on command line, to named printer.<\/p>\n<pre>root@tecmint:~# lpr -P deskjet-4620-series 1-final.pdf<\/pre>\n<p><strong>Note<\/strong>: The \u2018<strong>lpq<\/strong>\u2018 command lets you view the status of a printer (whether it\u2019s up or not), and the jobs (files) waiting to be printed.<\/p>\n<h3>35. Command: cmp<\/h3>\n<p>compare two files of any type and writes the results to the standard output. By default, \u2018<strong>cmp<\/strong>\u2018 Returns 0 if the files are the same; if they differ, the byte and line number at which the first difference occurred is reported.<\/p>\n<p>To provide examples for this command, lets consider two files:<\/p>\n<h5>file1.txt<\/h5>\n<pre>root@tecmint:~# cat file1.txt\r\nHi My name is Tecmint<\/pre>\n<h5>file2.txt<\/h5>\n<pre>root@tecmint:~# cat file2.txt\r\nHi My name is tecmint [dot] com<\/pre>\n<p>Now, let\u2019s compare two files and see output of the command.<\/p>\n<pre>root@tecmint:~# cmp file1.txt file2.txt \r\nfile1.txt file2.txt differ: byte 15, line 1<\/pre>\n<h3>36. Command: wget<\/h3>\n<p><strong>Wget<\/strong>\u00a0is a free utility for non-interactive (i.e., can work in background) download of files from the Web. It supports\u00a0<strong>HTTP<\/strong>,\u00a0<strong>HTTPS<\/strong>,\u00a0<strong>FTP<\/strong>\u00a0protocols and\u00a0<strong>HTTP<\/strong>\u00a0proxies.<\/p>\n<h4>Download ffmpeg using wget<\/h4>\n<pre>root@tecmint:~# wget http:\/\/downloads.sourceforge.net\/project\/ffmpeg-php\/ffmpeg-php\/0.6.0\/ffmpeg-php-0.6.0.tbz2\r\n--2013-05-22 18:54:52--  http:\/\/downloads.sourceforge.net\/project\/ffmpeg-php\/ffmpeg-php\/0.6.0\/ffmpeg-php-0.6.0.tbz2\r\nResolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.34.181.59\r\nConnecting to downloads.sourceforge.net (downloads.sourceforge.net)|216.34.181.59|:80... connected.\r\nHTTP request sent, awaiting response... 302 Found\r\nLocation: http:\/\/kaz.dl.sourceforge.net\/project\/ffmpeg-php\/ffmpeg-php\/0.6.0\/ffmpeg-php-0.6.0.tbz2 [following]\r\n--2013-05-22 18:54:54--  http:\/\/kaz.dl.sourceforge.net\/project\/ffmpeg-php\/ffmpeg-php\/0.6.0\/ffmpeg-php-0.6.0.tbz2\r\nResolving kaz.dl.sourceforge.net (kaz.dl.sourceforge.net)... 92.46.53.163\r\nConnecting to kaz.dl.sourceforge.net (kaz.dl.sourceforge.net)|92.46.53.163|:80... connected.\r\nHTTP request sent, awaiting response... 200 OK\r\nLength: 275557 (269K) [application\/octet-stream]\r\nSaving to: \u2018ffmpeg-php-0.6.0.tbz2\u2019\r\n100%[===========================================================================&gt;] 2,75,557    67.8KB\/s   in 4.0s   \r\n2013-05-22 18:55:00 (67.8 KB\/s) - \u2018ffmpeg-php-0.6.0.tbz2\u2019 saved [275557\/275557]<\/pre>\n<h3>37. Command: mount<\/h3>\n<p><strong>Mount<\/strong>\u00a0is an important command which is used to mount a filesystem that don\u2019t mount itself. You need root permission to mount a device.<\/p>\n<p>First run \u2018<strong>lsblk<\/strong>\u2018 after plugging-in your filesystem and identify your device and note down you device assigned name.<\/p>\n<pre>root@tecmint:~# lsblk \r\nNAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT \r\nsda      8:0    0 931.5G  0 disk \r\n\u251c\u2500sda1   8:1    0 923.6G  0 part \/ \r\n\u251c\u2500sda2   8:2    0     1K  0 part \r\n\u2514\u2500sda5   8:5    0   7.9G  0 part [SWAP] \r\nsr0     11:0    1  1024M  0 rom  \r\nsdb      8:16   1   3.7G  0 disk \r\n\u2514\u2500sdb1   8:17   1   3.7G  0 part<\/pre>\n<p>From this screen it was clear that I plugged in a\u00a0<strong>4 GB<\/strong>\u00a0pendrive thus \u2018<strong>sdb1<\/strong>\u2018 is my filesystem to be mounted. Become a\u00a0<strong>root<\/strong>\u00a0to perform this operation and change to\u00a0<strong>\/dev<\/strong>\u00a0directory where all the file system is mounted.<\/p>\n<pre>root@tecmint:~# su\r\nPassword:<\/pre>\n<pre>root@tecmint:~# cd \/dev<\/pre>\n<p>Create a directory named anything but should be relevent for reference.<\/p>\n<pre>root@tecmint:~# mkdir usb<\/pre>\n<p>Now mount filesystem \u2018<strong>sdb1<\/strong>\u2018 to directory \u2018<strong>usb<\/strong>\u2018.<\/p>\n<pre>root@tecmint:~# mount \/dev\/sdb1 \/dev\/usb<\/pre>\n<p>Now you can navigate to\u00a0<strong>\/dev\/usb<\/strong>\u00a0from terminal or\u00a0<strong>X-windows<\/strong>\u00a0system and acess file from the mounted directory.<\/p>\n<div align=\"center\"><strong>Time for\u00a0Code Developer\u00a0to know how rich Linux environment is<\/strong><\/div>\n<h3>38. Command: gcc<\/h3>\n<p><strong>gcc<\/strong>\u00a0is the in-built compiler for \u2018<strong>c<\/strong>\u2018 language in Linux Environment. A simple\u00a0<strong>c<\/strong>\u00a0program, save it on ur desktop as\u00a0<strong>Hello.c<\/strong>\u00a0(remember \u2018<strong>.c<\/strong>\u2018 extension is must).<\/p>\n<pre>#include &lt;stdio.h&gt;\r\nint main()\r\n{\r\nprintf(\"Hello world\\n\");\r\nreturn 0;\r\n}<\/pre>\n<h5>Compile it<\/h5>\n<pre>root@tecmint:~# gcc Hello.c<\/pre>\n<h5>Run it<\/h5>\n<pre>root@tecmint:~# .\/a.out \r\nHello world<\/pre>\n<p><strong>Note<\/strong>: On compiling a\u00a0<strong>c<\/strong>\u00a0program the output is automatically generated to a new file \u201c<strong>a.out<\/strong>\u201d and everytime you compile a\u00a0<strong>c<\/strong>\u00a0program same file \u201c<strong>a.out<\/strong>\u201d gets modified. Hence it is a good advice to define a output file during compile and thus there is no risk of overwrite to output file.<\/p>\n<h5>Compile it this way<\/h5>\n<pre>root@tecmint:~# gcc -o Hello Hello.c<\/pre>\n<p>Here \u2018<strong>-o<\/strong>\u2018 sends the output to \u2018<strong>Hello<\/strong>\u2018 file and not \u2018<strong>a.out<\/strong>\u2018. Run it again.<\/p>\n<pre>root@tecmint:~# .\/Hello \r\nHello world<\/pre>\n<h3>39. Command: g++<\/h3>\n<p><strong>g++<\/strong>\u00a0is the in-built compiler for \u2018<strong>C++<\/strong>\u2018 , the first object oriented programming language. A simple\u00a0<strong>c++<\/strong>\u00a0program, save it on ur desktop as\u00a0<strong>Add.cpp<\/strong>\u00a0(remember \u2018<strong>.cpp<\/strong>\u2018 extension is must).<\/p>\n<pre>#include &lt;iostream&gt;\r\nusing namespace std;\r\nint main() \r\n{\r\nint a;\r\nint b;\r\ncout&lt;&lt;\"Enter first number:\\n\";\r\ncin &gt;&gt; a;\r\ncout &lt;&lt;\"Enter the second number:\\n\";\r\ncin&gt;&gt; b;\r\ncin.ignore();\r\nint result = a + b;\r\ncout&lt;&lt;\"Result is\"&lt;&lt;\"  \"&lt;&lt;result&lt;&lt;endl;\r\ncin.get();\r\nreturn 0;\r\n}<\/pre>\n<h5>Compile it<\/h5>\n<pre>root@tecmint:~# g++ Add.cpp<\/pre>\n<h5>Run it<\/h5>\n<pre>root@tecmint:~# .\/a.out\r\nEnter first number: \r\n...\r\n...<\/pre>\n<p><strong>Note<\/strong>: On compiling a\u00a0<strong>c++<\/strong>\u00a0program the output is automatically generated to a new file \u201c<strong>a.out<\/strong>\u201d and everytime you compile a\u00a0<strong>c++<\/strong>\u00a0program same file \u201c<strong>a.out<\/strong>\u201d gets modified. Hence it is a good advice to define a output file during compile and thus there is no risk of overwrite to output file.<\/p>\n<h5>Compile it this way<\/h5>\n<pre>root@tecmint:~# g++ -o Add Add.cpp<\/pre>\n<h5>Run it<\/h5>\n<pre>root@tecmint:~# .\/Add \r\nEnter first number: \r\n...\r\n...<\/pre>\n<h3>40. Command: java<\/h3>\n<p><strong>Java<\/strong>\u00a0is one of the world\u2019s highly used programming language and is considered fast, secure, and reliable. Most of the the web based service of today runs on java.<\/p>\n<p>Create a simple java program by pasting the below test to a file, named\u00a0<strong>tecmint.java<\/strong>\u00a0(remember \u2018<strong>.java<\/strong>\u2018 extension is must).<\/p>\n<pre>class tecmint {\r\npublic static void main(String[] arguments) {\r\nSystem.out.println(\"Tecmint \");\r\n}\r\n}<\/pre>\n<h5>compile it using javac<\/h5>\n<pre>root@tecmint:~# javac tecmint.java<\/pre>\n<h5>Run it<\/h5>\n<pre>root@tecmint:~# java tecmint<\/pre>\n<p><strong>Note<\/strong>: Almost every distribution comes packed with\u00a0<strong>gcc compiler<\/strong>, major number of distros have inbuilt\u00a0<strong>g++<\/strong>\u00a0and\u00a0<strong>java compiler<\/strong>, while some may not have. You can\u00a0<strong>apt<\/strong>\u00a0or\u00a0<strong>yum<\/strong>\u00a0the required package.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Original Article tecmint.com 21. Command: Find Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories. root@tecmint:~# find -name *.sh .\/Desktop\/load.sh .\/Desktop\/test.sh .\/Desktop\/shutdown.sh .\/Binary\/firefox\/run-mozilla.sh .\/Downloads\/kdewebdev-3.5.8\/quanta\/scripts\/externalpreview.sh .\/Downloads\/kdewebdev-3.5.8\/admin\/doxygen.sh .\/Downloads\/kdewebdev-3.5.8\/admin\/cvs.sh .\/Downloads\/kdewebdev-3.5.8\/admin\/ltmain.sh .\/Downloads\/wheezy-nv-install.sh Note:\u00a0The `-name\u2018 option makes the search case sensitive. You can use the `-iname\u2018 option to find something regardless of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,2],"tags":[],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-general-commands","category-linux"],"_links":{"self":[{"href":"https:\/\/kidds.co.za\/index.php\/wp-json\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kidds.co.za\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kidds.co.za\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kidds.co.za\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kidds.co.za\/index.php\/wp-json\/wp\/v2\/comments?post=118"}],"version-history":[{"count":2,"href":"https:\/\/kidds.co.za\/index.php\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/kidds.co.za\/index.php\/wp-json\/wp\/v2\/posts\/118\/revisions\/121"}],"wp:attachment":[{"href":"https:\/\/kidds.co.za\/index.php\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kidds.co.za\/index.php\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kidds.co.za\/index.php\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}