Linux Commands frequently used by Linux Sysadmins – Part 1

What are some Linux commands used by Sysadmins and power users daily? In this article, I’ve listed 10 such commands frequently used. Suggestions and feedback are welcome. Also, see Part 2Part 3, Part 4, and Part 5.

Some people consider Linux a complicated operating system geared toward expert users only. However, as a free and open-source operating system, Linux is geared toward all users. Allowing end-users and admins access to understanding as much or as little as they desire.

Whether you are entirely new to Linux or an experienced admin,
you’ll use these commands frequently. (Part 1 of 5)

As such, the commands listed below should help you better navigate, manage, and search Linux systems. The Linux commands listed below are also helpful in grabbing more information when troubleshooting. These command-line tips apply to all Linux systems and distros on virtual and physical machines.

Linux commands examples


1. List and show all IP addresses associated with all network interfaces.

You may know this as the much longer command ip address show.

ip a

Example output:

[root@web ~]# ip a
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet brd scope global eth0
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet brd scope global eth1

ip command cheat sheet. (PDF)


2. List non-hidden files and subfolders in the current directory.

Use -R for recursive, -a to include hidden files or -l to use a per-line listing format. The cd command is discussed in Part 2.


example output:

[root@web /]# ls -l
total 36
drwx--x--x. 5 root root 76 Aug 11 03:28 backup
lrwxrwxrwx. 1 root root 7 Oct 30 2019 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Jun 26 05:45 boot
drwxr-xr-x. 20 root root 3120 Jun 6 06:07 dev
drwxr-xr-x. 99 root root 12288 Aug 12 07:40 etc
drwxr-xr-x. 8 root root 146 Feb 17 00:04 home


3. Display disk space usage.

Use -i to list inode information instead of block usage. Use -h to print sizes in powers of 1024 (e.g., 1023M).

df -h

Example output:

[user@server ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 17G 0 17G 0% /dev
/dev/mapper/root 313G 161G 153G 52% /
/dev/sdb1 1014M 266M 749M 27% /boot

Also popular is the du command. Used to estimate file space usage under a particular directory or files on the system.


4. Display memory usage.

Use -h to show all output fields automatically scaled to the shortest three-digit unit and display the units of print out. Or use -m to display the amount of memory in mebibytes.

free -m

Example output:

[root@web /]# free -h
total used free shared buff/cache available
Mem: 32G 2.0G 24G 1.6G 6.1G 28G
Swap: 16G 64M 16G
[root@web /]# free -m
total used free shared buff/cache available
Mem: 33016 2021 24746 1640 6248 28957
Swap: 16639 64 16575


5. Run multiple commands in one line using ; .



sudo apt update ; apt upgrade

Then optionally, you can add the final command to a bash script.


6. Find large files.

Or install ncdu and execute from the command line. Also, see the locate command in part 3.

find [directory] -size [set minimum size]


find /home/ -size +1000000k


7. Display a tree of processes.

Add -P to show PIDs.  PIDs are displayed as decimal numbers in parentheses after each process name.

pstree -P

Example output:

xxx@host:~$ pstree

Also, see the ps command in part 3.


8. Show a listing of the last logged-in users.


Example output:

[root@server ~]# last
root pts/0 Wed Aug 12 08:29 still logged in 
root pts/0 Wed Jul 29 10:52 - 12:13 (01:21) 
root pts/0 xxx.xx.xx.xx Mon Jul 27 23:11 - 00:10 (00:58) 
root pts/0 Wed Jul 15 23:46 - 00:01 (00:15)


9. Show a list of currently logged-in user sessions.


Example output:

root@host:~$ w
13:08:25 up 72 days, 8:00, 1 user, load average: 0.01, 0.08, 0.08
xxxx-user pts/0 13:04 0.00s 0.00s 0.00s w


10. Search a file for a pattern of characters, then display all matching lines.


For example:

grep [options] pattern [files]

For example, grep directory recursively:

grep -r "texthere" /home/

For example, grep the word printf:

grep printf /path/filename.txt

For example, find previously used commands which include systemctl

history | grep systemctl

For example, find the last login(s) for username:

last | grep username


Last week, a reader posted a comment on a recent blog post requesting that some articles be a bit more beginner-friendly and quick and to the point. With this feedback in mind, this article serves as part 1 of 5.

Next – Linux Commands frequently used by Linux Sysadmins – Part 2 >

See also:

Tags: , , , ,

Top ↑