Daily monitoring and debugging of Linux system performance is a heavy task for the system and network administrators. Five years after working as a Linux system administrator in the IT field, I gradually realized how difficult IT is to monitor and keep the system up and running. For this reason, we have compiled the list of 18 most commonly used command line tools that will help every Linux/Unix system administrator. These command line tools can be used in various Linux systems to monitor and find the causes of performance problems. This command line tool list provides enough tools for you to select a tool suitable for your monitoring scenario.
1. Top-Linux Process Monitoring
The Top command in Linux is a performance monitoring program. Many System Administrators often use it to monitor Linux performance. This command is available in many Linux or Unix-like operating systems. The Top command is used to display all running and Active Real-Time Processes in a certain order, and regularly update the display results. This command displays the CPU usage, memory usage, swap memory usage, Cache Usage, buffer usage, process PID, commands used, and others. It can also display the memory and CPU usage of running processes. For the system administrator, the top command is very useful. It can be used to monitor the system and take correct actions when necessary. Let's take a look at the top command in practice.
# top
For more examples of Top commands, see the following 12 examples of using Top commands in Linux.
2. VmStat-Virtual Memory statistics
The VmStat command in Linux is used to display statistics of virtual memory, kernel threads, disks, system processes, I/O blocks, interruptions, and CPU activity. By default, the vmstat command is unavailable in Linux. You need to install a sysstat package containing the vmstat program. Common usage of command format is:
- [root@ithomer ~]# vmstat
- procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
- r b swpd free buff cache si so bi bo in cs us sy id wa st
- 0 0 0 105368 90900 257588 0 0 9 33 4 11 2 0 97 0 0
For more examples of vmstat, see Vmstat command instances in Linux 6.
3. Lsof-list opened files
In many Linux or Unix-like systems, lsof commands are commonly used to display all open files and processes in a list. Open files include disk files, network sockets, pipelines, devices, and processes. One of the main cases of using this command is when the disk cannot be mounted and an error message is displayed that is in use or a file is opened. Using this command, you can easily see which file is being used. The most common format of this command is as follows:
- # lsof
- COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
- init 1 root cwd DIR 104,2 4096 2 /
- init 1 root rtd DIR 104,2 4096 2 /
- init 1 root txt REG 104,2 38652 17710339 /sbin/init
- init 1 root mem REG 104,2 129900 196453 /lib/ld-2.5.so
- init 1 root mem REG 104,2 1693812 196454 /lib/libc-2.5.so
- init 1 root mem REG 104,2 20668 196479 /lib/libdl-2.5.so
- init 1 root mem REG 104,2 245376 196419 /lib/libsepol.so.1
- init 1 root mem REG 104,2 93508 196431 /lib/libselinux.so.1
- init 1 root 10u FIFO 0,17 953 /dev/initctl
For more information about the usage and examples of lsof commands, see 10 examples of lsof commands in Linux.
4. Tcpdump-network package analyzer
Tcpdump is one of the most widely used network packet analyzer or package monitoring programs. It is used to capture or filter TCP/IP packets received or transmitted on a specified interface on the network. It also has an option to save the captured package to the file for later analysis. Tcpdump can be used in almost all major Linux releases.
- # tcpdump -i eth0tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
- listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
- 22:08:59.617628 IP tecmint.com.ssh > 115.113.134.3.static-mumbai.vsnl.net.in.28472: P 2532133365:2532133481(116) ack 3561562349 win 9648
- 22:09:07.653466 IP tecmint.com.ssh > 115.113.134.3.static-mumbai.vsnl.net.in.28472: P 116:232(116) ack 1 win 9648
- 22:08:59.617916 IP 115.113.134.3.static-mumbai.vsnl.net.in.28472 > tecmint.com.ssh: . ack 116 win 64347
For more information about tcpdump usage, see 12 examples of using Tcpdump commands in Linux.
5. Netstat-network status statistics
Netstat is a command line tool used to monitor inbound and outbound packets and network interface statistics. It is a very useful tool that the system administrator can use to monitor network performance, locate and solve network problems.
- # netstat -a | moreActive Internet connections (servers and established)
- Proto Recv-Q Send-Q Local Address Foreign Address State
- tcp 0 0 *:mysql *:* LISTEN
- tcp 0 0 *:sunrpc *:* LISTEN
- tcp 0 0 *:realm-rusd *:* LISTEN
- tcp 0 0 *:ftp *:* LISTEN
- tcp 0 0 localhost.localdomain:ipp *:* LISTEN
- tcp 0 0 localhost.localdomain:smtp *:* LISTEN
- tcp 0 0 localhost.localdomain:smtp localhost.localdomain:42709 TIME_WAIT
- tcp 0 0 localhost.localdomain:smtp localhost.localdomain:42710 TIME_WAIT
- tcp 0 0 *:http *:* LISTEN
- tcp 0 0 *:ssh *:* LISTEN
- tcp 0 0 *:https *:* LISTEN
For more examples of Netstat, see 20 examples of using the Netstat command in Linux.
6. Htop-Linux Process Monitoring
Htop is a very advanced interactive real-time linux Process Monitoring Tool. It is very similar to the top command, but it has more features, such as user-friendly management of processes, shortcut keys, vertical and horizontal display processes and so on. Htop is a third-party tool that is not included in the linux system. You need to install it using the YUM package management tool.
CentOS command installation: yum install htop,