STS Host and Tech Knowledge base
Search
Close this search box.

Frequently Common Linux Commands for Administrators

Useful Common Linux Commands for System Administrators

System Administrators have to know some important and useful Linux commands, also they should understand and be aware about some critical commands. In this article we will explain about the most common Linux commands.

Uptime Linux Command

 This command shows how long your system has been running, it also shows the number of users currently logged into the system and shows the average download for 1.5 and 15 minutes intervals.

				
					Uptime
15:19:25 up 12 days, 22:50, 1 user, load average: 0.02, 0.12, 0.19
				
			

W Linux Command

This command used to show information about the users currently on the Server , and the processes they are doing. 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:

    • -f : Remove From: “Looged IP” from displays.
    • -s : Remove JCPU and PCPU from displays.
    • -h : Displays no header entries.
    • -V : (upper letter) – Shows versions.
				
					w
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 127.0.0.1 15:19 5.00s 0.08s 0.00s w
				
			

Users Linux Command

displays the current logged in users.

				
					users
root
				
			

Who Linux Command

 It’s similar to w. Unlike the w command, which does not print how the user processes.

         The command has the following options:

  • -a, –all : Displays all information in cumulatively.
  • -r : Shows current runlet.
  • -b : Displays last system reboot date time.
  •  
				
					who
root pts/0 2016-12-13 15:19 (127.0.2.1)
				
			

 Whoami Linux Command

Shows the current user, for example if you are logged as root the result will be root.

				
					whoami
root
				
			

 ls Linux Command

Shows a list of files in a human-readable format for the current location. You can use ls -ltr to display the result with sort files by last modified time.

				
					ls -l
total 28
drwx–x–x 6 root root 4096 Dec 13 02:00 BackupDataFolder
-rw-r–r– 1 root root 236 Nov 27 19:12 install.log
drwxr-xr-x 2 root root 4096 Dec 12 21:57 tempfolder

				
			

 Crontab Linux Commands

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 editor.

				
					crontab -l
00 * 20 * * /bin/local >/job.php
15 * * * * /bin/jobs >/job1.php

				
			

More Linux Command

It allows to view the file quickly and shows details in percentage. You can page up and down. By Pressing ‘q’ letter you can quit from more window command.

				
					more installapp.log
Installing filesystem-1.6.4.i86
Installing xml-curl-1.3.4.i64
Installing iso-codes-3.16-2.el6.noarch
–More–(20%)

				
			

 Less Linux Command

It allows to view file quickly . You can page up and down. By Pressing ‘q’ letter you can quit from less window command.

				
					less installapp.log
Installing filesystem-1.6.4.i86
Installing xml-curl-1.3.4.i64
Installing iso-codes-3.16-2.el6.noarch


				
			

 Copy Linux Command

It is used to copy file from source to destination . Or use this 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 Linux Command

We use this command to edit the file ,after showing the file contents Press “i” to start editing the file .Press ESC to end edit and then type :wq to write the update.

				
					vi /etc/config.txt
				
			

 SSH Linux Command

It used to login into your 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 Linux Commands

It is used for connecting to a remote server using FTP or Remote Secure FTP.
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 server.

				
					ftp [Remote IP]
sftp [Remote IP]

				
			

Service Linux Commands

It allows you to start /stop and restart the Linux services.

				
					service httpd start — Start httpd service
service httpd stop — Stop httpd service
service httpd restart — Restart httpd service
service httpd status — Show httpd service Status The Next is example result:
httpd.service – Apache web server managed by cPanel EasyApache

				
			

 Memory Linux Command

Free command show free, total and swap ,available memory information in bytes .

				
					free
total used free shared buff/cache available
Mem: 60229664 901560 512044 1338828 58816060 57705696
Swap: 0 0 0

				
			

 Top Linux Command

Shows the processor activity of your system ,also shows tasks managed by kernel in real-time. Press “q” To quite the window.

				
					top
top – 19:29:20 up 13 days, 2:59, 1 user, load average: 0.02, 0.04, 0.05
Tasks: 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 st
KiB Mem : 60229664 total, 501920 free, 903428 used, 58824316 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 57695652 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8491 root 20 0 155796 2192 1528 R 0.7 0.0 0:00.03 top

				
			

Extract Zipped file Linux Commands

The following show how to Extract “.zip”,”.tar”,”tar.gz”,”.rar”.

				
					unzip archive.zip — Extract .zip file
tar -xvf archive.tar — Extract .tar file
tar -zxvf archive.tar.gz — Extract .tar.gz file
rar x archive.rar — Extract .rar file
tar -zcf archive-name.tar.gz foldername/ — Extract .tar.gz file to foldername
				
			

Grep Search Linux Commands

It used to search for the string in all files of the current folder ,or to search for the keyword in a file contents.

				
					grep -ir searchkeyword * — Search searchkeyword in all files inside the current folder
grep -r searchkeyword /var/www/vhosts/file.logs — Search searchkeyword in file.logs

				
			

 lsof Linux Command

Display the current of all opened files , you can specify the opened files by user

				
					lsof — display all opened files
lsof -u root — display all opened files by user root
 
				
			

 last Linux Command

Display user’s activity in the system.

				
					last — For all Users
root pts/1 127.0.0.1 Tue Dec 13 19:44 still logged in
root pts/0 127.0.0.1 Tue Dec 13 15:19 still logged in
jone 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 User
root pts/1 127.0.0.1 Tue Dec 13 19:44 still logged in
root pts/0 127.0.0.1 Tue Dec 13 15:19 still logged in
root pts/0 127.0.0.1 Thu Dec 1 10:27 – 01:48 (07:11)

				
			

Remove File Linux Commands

Command with options to remove or delete files.

				
					file-name — delete a file without prompting for confirmation
rm -i tetfilename.txt — delete a file with prompting for confirmation
rm: remove regular file ‘tetfilename.txt’?

				
			

Folders Linux Commands

For making new directory or removing directory.

				
					mkdir newdirectory — create new newdirectory directory on the current folder
rm -rf “directory name” — remove the “directory name” and its sub folders and files

				
			

Disk Space Linux Command

 Determines your available disk space in Linux and Unix.

				
					df -h — dispaly Linux Disk Space Information
Filesystem 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% /mount2
tmpfs 100G 0 100G 0% /run/sub/10

				
			

Share Article

Related Articles