{"id":368,"date":"2016-12-28T17:54:13","date_gmt":"2016-12-28T17:54:13","guid":{"rendered":"https:\/\/www.xsofthost.com\/help\/?p=368"},"modified":"2017-09-01T11:59:58","modified_gmt":"2017-09-01T11:59:58","slug":"common-frequently-useful-linux-commands-for-system-administrators","status":"publish","type":"post","link":"https:\/\/www.xsofthost.com\/help\/common-frequently-useful-linux-commands-for-system-administrators\/","title":{"rendered":"Frequently Common Linux Commands for Administrators"},"content":{"rendered":"<h2>Useful Common Linux Commands for System Administrators<\/h2>\n<p>This article help System Administrators to learn common useful and frequently used Linux or Unix commands some commands are critical and we should be aware and understand the commands carefully before run it on your VPS or dedicated servers.<\/p>\n<ol>\n<li>\n<p><strong>Uptime Command<\/strong> :uptime command shows since how long your system is up and running ,also show the number of users are currently logged in in the system and displays load average for 1,5 and 15 minutes intervals.<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">uptime<\/span><\/div>\n<div>15:19:25 up 12 days, 22:50, 1 user, load average: 0.02, 0.12, 0.19<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>W Command <\/strong> : W displays information about the users currently on the Server , and show user&#8217;s processes. The header shows, in this order, the current time,how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes .The command has the following options:<\/p>\n<div>\n<ul>\n<li>-f : Remove From &#8220;Looged IP&#8221; from displays.<\/li>\n<li>-s : Remove JCPU and PCPU from displays.<\/li>\n<li>-h : displays no header entries.<\/li>\n<li>-V : <strong>(upper letter)<\/strong> \u2013 Shows versions.<\/li>\n<\/ul>\n<\/div>\n<p><\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">w<\/span><\/div>\n<div>USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT<\/div>\n<div>root pts\/0 127.0.0.1 15:19 5.00s 0.08s 0.00s w<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Users Command<\/strong> :displays the current logged in users.<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">users<\/span><\/div>\n<div>root<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Who Command<\/strong> :who command is similar to w command. Unlike w command who doesn\u2019t print how user&#8217;s processes.<\/p>\n<p>The command has the following options:<\/p>\n<ul>\n<li>-a, \u2013all : Displays all information in cumulatively.<\/li>\n<li>-r : Shows current runlet.<\/li>\n<li>-b : Displays last system reboot date time.<\/li>\n<\/ul>\n<p><\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">who<\/span><\/div>\n<div>root pts\/0 2016-12-13 15:19 (127.0.2.1)<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Whoami Command<\/strong> :display the current user, as example if you are logged as root the result will be root.<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">whoami<\/span><\/div>\n<div>root<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>ls Command<\/strong> :ls command display list of files in human readable format for the current location. You can use <strong>ls -ltr<\/strong> to display the result with sort files by last modified time.<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">ls -l<\/span><\/div>\n<div>total 28<\/div>\n<div>drwx&#8211;x&#8211;x 6 root root 4096 Dec 13 02:00 BackupDataFolder<\/div>\n<div>-rw-r&#8211;r&#8211; 1 root root 236 Nov 27 19:12 install.log<\/div>\n<div>drwxr-xr-x 2 root root 4096 Dec 12 21:57 tempfolder<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Crontab Command<\/strong> :The crontab is a list of commands that you want to run on a regular schedule, and also the name of the command used to manage that list. The <strong>crontab -l<\/strong> will display list of cron schedule jobs<\/p>\n<p><strong>crontab -e<\/strong>: This will open the crontab in a text editor<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">crontab -l<\/span><\/div>\n<div>00 * 20 * * \/bin\/local &gt;\/job.php<\/div>\n<div>15 * * * * \/bin\/jobs &gt;\/job1.php<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>More Command<\/strong> :more command allows quickly view file and shows details in percentage. You can page up and down. By Pressing &#8216;q&#8217; letter you can quit from more window command.<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">more installapp.log<\/span><\/div>\n<div>Installing filesystem-1.6.4.i86<\/div>\n<div>Installing xml-curl-1.3.4.i64<\/div>\n<div>Installing iso-codes-3.16-2.el6.noarch<\/div>\n<div>&#8211;More&#8211;(20%)<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Less Command<\/strong> :more command allows quickly view file . You can page up and down. By Pressing &#8216;q&#8217; letter you can quit from less window command.<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">less installapp.log<\/span><\/div>\n<div>Installing filesystem-1.6.4.i86<\/div>\n<div>Installing xml-curl-1.3.4.i64<\/div>\n<div>Installing iso-codes-3.16-2.el6.noarch<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Copy Command<\/strong> :Copy file from source to destination . Or you can use the command <strong>cp -i sourcefile destinationfile<\/strong> To prompt before overwrite file.<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">cp -p sourcefile destinationfile<\/span><\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Print Working Directory Command<\/strong> : Show the current directory for the current logged user session.<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">pwd <\/span><\/div>\n<div>\/var\/Backup<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>VI Command<\/strong> : for editing the file after showing the file contents Press &#8220;i&#8221; to start edit the file and press ESC to end edit and then type :wq to write the update .<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">vi \/etc\/config.txt <\/span><\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>SSH Command<\/strong> : SSH command is used to login into remote host server by passing IP address with username .<\/p>\n<p>To check the version of ssh use option -V <strong>(uppercase)<\/strong>.<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">ssh root@[Remote IP] <\/span><\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Ftp\/sftp Command<\/strong> : To connect to remote server using FTP protocol or sftp to remote secure FTP protocol .<\/p>\n<p>To check the version of ssh use option -V <strong>(uppercase)<\/strong>.<\/p>\n<p>To ignore the SSL certificate use <strong>set ssl:verify-certificate no<\/strong> after you logged to remote ftp server<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">ftp [Remote IP] <\/span><\/div>\n<div><span class=\"prompt\">sftp [Remote IP] <\/span><\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Service Command<\/strong> : The service command allow you to start stop and restart the Linux services .<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">service httpd start <\/span> &#8212; Start httpd service<\/div>\n<div><span class=\"prompt\">service httpd stop <\/span> &#8212; Stop httpd service<\/div>\n<div><span class=\"prompt\">service httpd restart <\/span> &#8212; Restart httpd service<\/div>\n<div><span class=\"prompt\">service httpd status <\/span> &#8212; Show httpd service Status The Next is example result:<\/div>\n<div>httpd.service &#8211; Apache web server managed by cPanel EasyApache<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Memory Command<\/strong> : free command show free, total and swap ,available memory information in bytes .<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">free<\/span><\/div>\n<div>total used free shared buff\/cache available<\/div>\n<div>Mem: 60229664 901560 512044 1338828 58816060 57705696<\/div>\n<div>Swap: 0 0 0<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Top Command<\/strong> : displays processor activity of your system and also displays tasks managed by kernel in real-time. To quite the window press &#8220;q&#8221;<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">top<\/span><\/div>\n<div>top &#8211; 19:29:20 up 13 days, 2:59, 1 user, load average: 0.02, 0.04, 0.05<\/div>\n<div>Tasks: 53 total, 1 running, 152 sleeping, 0 stopped, 0 zombie<\/div>\n<div>%Cpu(s): 0.0 us, 0.2 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st<\/div>\n<div>KiB Mem : 60229664 total, 501920 free, 903428 used, 58824316 buff\/cache<\/div>\n<div>KiB Swap: 0 total, 0 free, 0 used. 57695652 avail Mem<\/div>\n<div>PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND<\/div>\n<div>8491 root 20 0 155796 2192 1528 R 0.7 0.0 0:00.03 top<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Extract Zipped file Command<\/strong> : the following show how to Extract &#8220;.zip&#8221;,&#8221;.tar&#8221;,&#8221;tar.gz&#8221;,&#8221;.rar&#8221;<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">unzip archive.zip<\/span> &#8212; Extract .zip file<\/div>\n<div><span class=\"prompt\">tar -xvf archive.tar<\/span> &#8212; Extract .tar file<\/div>\n<div><span class=\"prompt\">tar -zxvf archive.tar.gz<\/span> &#8212; Extract .tar.gz file<\/div>\n<div><span class=\"prompt\">rar x archive.rar<\/span> &#8212; Extract .rar file<\/div>\n<div><span class=\"prompt\">tar -zcf archive-name.tar.gz foldername\/<\/span> &#8212; Extract .tar.gz file to foldername<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Grep Search Command<\/strong> : grep command search string in all files in the current folder ,or search keyword in a file contents<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">grep -ir searchkeyword *<\/span> &#8212; Search searchkeyword in all files inside the current folder<\/div>\n<div><span class=\"prompt\">grep -r searchkeyword \/var\/www\/vhosts\/file.logs<\/span> &#8212; Search searchkeyword in file.logs<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong> lsof Command<\/strong> : display the currnet of all opened files , you can specify the opened files by user<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">lsof <\/span> &#8212; display all opened files<\/div>\n<div><span class=\"prompt\">lsof -u root<\/span> &#8212; display all opened files by user root<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong> last Command<\/strong> : display user&#8217;s activity in the system<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">last <\/span> &#8212; For all Users<\/div>\n<div>root pts\/1 127.0.0.1 Tue Dec 13 19:44 still logged in<\/div>\n<div>root pts\/0 127.0.0.1 Tue Dec 13 15:19 still logged in<\/div>\n<div>jone pts\/0 127.0.0.1 Mon Dec 12 22:36 &#8211; 01:48 (03:11)<\/div>\n<div>root pts\/0 127.0.0.1 Thu Dec 1 10:27 &#8211; 01:48 (07:11)<\/div>\n<div><span class=\"prompt\">last root<\/span> &#8212; For root User<\/div>\n<div>root pts\/1 127.0.0.1 Tue Dec 13 19:44 still logged in<\/div>\n<div>root pts\/0 127.0.0.1 Tue Dec 13 15:19 still logged in<\/div>\n<div>root pts\/0 127.0.0.1 Thu Dec 1 10:27 &#8211; 01:48 (07:11)<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong> Remove File Command<\/strong> : Command with options to remove or delete files<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">rm file-name <\/span> &#8212; delete a file without prompting for confirmation<\/div>\n<div><span class=\"prompt\">rm -i tetfilename.txt <\/span> &#8212; delete a file with prompting for confirmation<\/div>\n<div>rm: remove regular file &#8216;tetfilename.txt&#8217;?<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Folders Command<\/strong> : Commands to make new directory or remove directory<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">mkdir newdirectory <\/span> &#8212; create new newdirectory directory on the current folder<\/div>\n<div><span class=\"prompt\">rm -rf &#8220;directory name&#8221; <\/span> &#8212; remove the &#8220;directory name&#8221; and its sub folders and files<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong> Disk Space Command<\/strong> : Determine how much disk space You have in Linux and Unix<\/p>\n<div class=\"cmd\">\n<div><span class=\"prompt\">df -h <\/span> &#8212; dispaly Linux Disk Space Information<\/div>\n<div>Filesystem Size Used Avail Use% Mounted on<\/div>\n<div>\/dev\/sda1 1500G 320G 1468G 2% \/<\/div>\n<div>\/dev\/sdb1 1500G 520G 980G 35% \/mount1<\/div>\n<div>\/dev\/sdc1 1500G 1000G 500G 66% \/mount2<\/div>\n<div>tmpfs 100G 0 100G 0% \/run\/sub\/10<\/div>\n<\/div>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Useful Common Linux Commands for System Administrators This article help System Administrators to learn common useful and frequently used Linux or Unix commands some commands are critical and we should be aware and understand the commands carefully before run it on your VPS or dedicated servers. Uptime Command :uptime command shows since how long your [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":363,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[41],"tags":[178,42,50,74],"_links":{"self":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts\/368"}],"collection":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/comments?post=368"}],"version-history":[{"count":6,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts\/368\/revisions"}],"predecessor-version":[{"id":374,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts\/368\/revisions\/374"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/media\/363"}],"wp:attachment":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/media?parent=368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/categories?post=368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/tags?post=368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}