In this article we are going to cover 20 Linux Monitoring Commands You Should Know as a System Admin/Linux System Admin/DevOps/SRE.
If you are working as a System Administrator/Linux Admin/DevOps/SRE then most probably you will need to deal with performance-related issues in the Linux environment. Let’s go through some of the most used Linux command-line utilities to diagnose network and performance-related issues
Linux Monitoring Commands
When we will run this command it will open an interactive command mode. Where the top half portion will contain the statistics of processes and resource usage. And Lower half contains a list of the currently running processes.
Pressing q will simply exit the command mode.
The vmstat command is a Linux Utility for displaying statistics related to memory consumption, disk usage and other system information.
vmstat must not be present in your Linux System but no worries.
We can install easily under package “ sysstat”
The iostat command in Linux lets you monitor CPU utilization and I/O (input/output) statistics of all the disks and file systems.
iostat commands are useful for changing system configuration to better balance the i/o load between physical disks.
This command is mostly used by Linux System Administrators.
4. iostat -d
The iostat -d command is used for monitoring system input/output device loading by observing the time the devices are active related to their average transfer rates.
iostat -d command is used to display the device utilization report.
The job of lsof command is to “list open files” in the system.
An open file does not mean pdf or a text file, it includes disk files or pipes used by processes in the background.
This command is a handy tool for Operating System debuggers and system administrators.
The tcpdump is a tool that is used for TCP/IP packet analysis.
This command is commonly used for traffic analyzer on Linux, as well as many other operating systems.
tcpdump allows you to sniff all traffic that goes in and out of all interfaces.
More importantly, it has the ability to filter the traffic by interface, host, destination or source host, type of traffic, and many other criteria.
We can also save the captured packets in a file for later analysis.
netstat command displays various network related information such as network connections, routing tables, interface statistics, multicast memberships, etc.
netstat is used for monitoring incoming and outgoing network packets.
8. netstat -s
The netstat -s command print out network statistics like total number of packets received and transmitted by protocol type and so on.
To print statistics of only select protocols like TCP or UDP use the corresponding options like t and u along with the s option.
9. ps -ef | grep PID
ps command will print four columns of information for two minimum processes running in current shell.
The -e option instructs ps to display all processes.
The -f option stands for full format listing which provides detailed information about the processes.
ps -ef | grep apache
NetHogs is a small net top tool.
Instead of breaking the traffic down per protocol or per subnet, like most such tools do, it groups bandwidth by process and does not rely on a special kernel module to be loaded.
If there’s suddenly a lot of network traffic, you can fire up NetHogs and immediately see which PID is causing this, and if it’s some kind of spinning process, kill it.
Using mpstat command will display the Global Average Activities by All CPUs.
We are able to display overall CPU statistics per system or per processor through mpstat command.
12. free -m
Free -m is a command that displays used memory in our system.
Free -m command also displays the available memory in our system.
uptime command displays that how long does the system has been running.
It also displays how many users are logged in.
14. ps -e
The ps command helps you to view details of currently-running processes.
We can also kill or terminate processes that are not behaving normally.
This will list all the processes running and also those process which are started by other users.
The ac command displays the report of connect time(hrs) of that system on the basis of login and logout timings.
It is stored in wtmp file.
16. ac -d
The ac -d cpmmand prints total for each day than just one total at end.
17. ac -p
The ac -p command prints total time for each user in addition to the everything into a value.
18. vmstat -m
The vmstat tool is used to monitor system’s virtual memory usage.
The vmstat -m command displays the slap information of your virtual machine.
19. vmstat –d
The vmstat -d displays the disk statistics of the virtual memory of our system.
The vmstat -d tool is used to monitor system’s virtual memory usage.
The pstree command shows a inheritance structure of processes.
pstree command displays that which command is children of other command.
We have covered Linux Monitoring Commands You Should Know as a System Admin/Linux System Admin/DevOps/SRE.