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 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.uptime15:19:25 up 12 days, 22:50, 1 user, load average: 0.02, 0.12, 0.19
W Command : W displays information about the users currently on the Server , and show user’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:
wUSER TTY FROM LOGIN@ IDLE JCPU PCPU WHATroot pts/0 127.0.0.1 15:19 5.00s 0.08s 0.00s w
- -f : Remove From “Looged IP” from displays.
- -s : Remove JCPU and PCPU from displays.
- -h : displays no header entries.
- -V : (upper letter) – Shows versions.
Users Command :displays the current logged in users.usersroot
Who Command :who command is similar to w command. Unlike w command who doesn’t print how user’s processes.
The command has the following options:
whoroot pts/0 2016-12-13 15:19 (127.0.2.1)
- -a, –all : Displays all information in cumulatively.
- -r : Shows current runlet.
- -b : Displays last system reboot date time.
Whoami Command :display the current user, as example if you are logged as root the result will be root.whoamiroot
ls Command :ls command display list of files in human readable format for the current location. You can use ls -ltr to display the result with sort files by last modified time.ls -ltotal 28drwx–x–x 6 root root 4096 Dec 13 02:00 BackupDataFolder-rw-r–r– 1 root root 236 Nov 27 19:12 install.logdrwxr-xr-x 2 root root 4096 Dec 12 21:57 tempfolder
Crontab Command :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 crontab -l will display list of cron schedule jobs
crontab -e: This will open the crontab in a text editorcrontab -l00 * 20 * * /bin/local >/job.php15 * * * * /bin/jobs >/job1.php
More Command :more command allows quickly view file and shows details in percentage. You can page up and down. By Pressing ‘q’ letter you can quit from more window command.more installapp.logInstalling filesystem-1.6.4.i86Installing xml-curl-1.3.4.i64Installing iso-codes-3.16-2.el6.noarch–More–(20%)
Less Command :more command allows quickly view file . You can page up and down. By Pressing ‘q’ letter you can quit from less window command.less installapp.logInstalling filesystem-1.6.4.i86Installing xml-curl-1.3.4.i64Installing iso-codes-3.16-2.el6.noarch
Copy Command :Copy file from source to destination . Or you can use the command cp -i sourcefile destinationfile To prompt before overwrite file.cp -p sourcefile destinationfile
Print Working Directory Command : Show the current directory for the current logged user session.pwd/var/Backup
VI Command : for editing the file after showing the file contents Press “i” to start edit the file and press ESC to end edit and then type :wq to write the update .vi /etc/config.txt
SSH Command : SSH command is used to login into remote host server by passing IP address with username .
To check the version of ssh use option -V (uppercase).ssh root@[Remote IP]
Ftp/sftp Command : To connect to remote server using FTP protocol or sftp to remote secure FTP protocol .
To check the version of ssh use option -V (uppercase).
To ignore the SSL certificate use set ssl:verify-certificate no after you logged to remote ftp serverftp [Remote IP]sftp [Remote IP]
Service Command : The service command allow you to start stop and restart the Linux services .service httpd start — Start httpd serviceservice httpd stop — Stop httpd serviceservice httpd restart — Restart httpd serviceservice httpd status — Show httpd service Status The Next is example result:httpd.service – Apache web server managed by cPanel EasyApache
Memory Command : free command show free, total and swap ,available memory information in bytes .freetotal used free shared buff/cache availableMem: 60229664 901560 512044 1338828 58816060 57705696Swap: 0 0 0
Top Command : displays processor activity of your system and also displays tasks managed by kernel in real-time. To quite the window press “q”toptop – 19:29:20 up 13 days, 2:59, 1 user, load average: 0.02, 0.04, 0.05Tasks: 53 total, 1 running, 152 sleeping, 0 stopped, 0 zombie%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 stKiB Mem : 60229664 total, 501920 free, 903428 used, 58824316 buff/cacheKiB Swap: 0 total, 0 free, 0 used. 57695652 avail MemPID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND8491 root 20 0 155796 2192 1528 R 0.7 0.0 0:00.03 top
Extract Zipped file Command : the following show how to Extract “.zip”,”.tar”,”tar.gz”,”.rar”unzip archive.zip — Extract .zip filetar -xvf archive.tar — Extract .tar filetar -zxvf archive.tar.gz — Extract .tar.gz filerar x archive.rar — Extract .rar filetar -zcf archive-name.tar.gz foldername/ — Extract .tar.gz file to foldername
Grep Search Command : grep command search string in all files in the current folder ,or search keyword in a file contentsgrep -ir searchkeyword * — Search searchkeyword in all files inside the current foldergrep -r searchkeyword /var/www/vhosts/file.logs — Search searchkeyword in file.logs
lsof Command : display the currnet of all opened files , you can specify the opened files by userlsof — display all opened fileslsof -u root — display all opened files by user root
last Command : display user’s activity in the systemlast — For all Usersroot pts/1 127.0.0.1 Tue Dec 13 19:44 still logged inroot pts/0 127.0.0.1 Tue Dec 13 15:19 still logged injone pts/0 127.0.0.1 Mon Dec 12 22:36 – 01:48 (03:11)root pts/0 127.0.0.1 Thu Dec 1 10:27 – 01:48 (07:11)last root — For root Userroot pts/1 127.0.0.1 Tue Dec 13 19:44 still logged inroot pts/0 127.0.0.1 Tue Dec 13 15:19 still logged inroot pts/0 127.0.0.1 Thu Dec 1 10:27 – 01:48 (07:11)
Remove File Command : Command with options to remove or delete filesrm file-name — delete a file without prompting for confirmationrm -i tetfilename.txt — delete a file with prompting for confirmationrm: remove regular file ‘tetfilename.txt’?
Folders Command : Commands to make new directory or remove directorymkdir newdirectory — create new newdirectory directory on the current folderrm -rf “directory name” — remove the “directory name” and its sub folders and files
Disk Space Command : Determine how much disk space You have in Linux and Unixdf -h — dispaly Linux Disk Space InformationFilesystem Size Used Avail Use% Mounted on/dev/sda1 1500G 320G 1468G 2% //dev/sdb1 1500G 520G 980G 35% /mount1/dev/sdc1 1500G 1000G 500G 66% /mount2tmpfs 100G 0 100G 0% /run/sub/10
1,450 total views, 1 views today