If you are working as a support in a production environment 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 performance-related issues. Note: Some of the commands listed below may not be installed by default, so you got to install them manually.

lsof

lsof stands for “list open files” to help you to find all the opened files and processes along with the one who opened them. The lsof utility can be convenient to use in some scenarios. To list, all the files opened by a particular PID. Count number of files & processes Check the currently opened log file Find out the port number used by the process Check out more lsof command examples.

pidstat

pidstat can be used to monitor tasks managed by the Linux kernel. Troubleshooting I/O related issues can be easy with this command. List I/O statistics of all the PID To displace I/O stats for particular PID If you are doing real-time troubleshooting for some process, then you can monitor the I/O in an interval. The below example is to monitor every 5 seconds.

top

Probably one of the most used commands on Linux would be top. The top command can be used to display system summary information and current utilization. Just executing the top command can show you CPU utilization, process details, a number of tasks, memory utilization, a number of zombie processes, etc. To display process details for specific user To kill the process, you can execute the top and press k. It will prompt you to enter the PID to be killed.

ps

ps stands for process status and widely used command to get a snapshot of the running process. Very useful to find out if a process is running or not and if running then prints PID. To find out the PID and process details by some word

tcpdump

Troubleshooting network issue is always challenging, and one of the essential commands to use is tcpdump. You can use tcpdump to capture the network packets on a network interface. To capture the packets on a particular network interface As you can see above has captured the traffic flow on eth0 interface. To capture network traffic between source and destination IP Capture network traffic for destination port 443 Read the captured file Ex: to read an above-captured file Learn more about tcpdump to capture and analyze the network traffic.

iostat

iostat stands for input-output statistics and often used to diagnose a performance issue with storage devices. You can monitor CPU, Device & Network file system utilization report with iostat. Display disk I/O statistics Display CPU statistics

ldd

ldd stands for list dynamic dependencies to show shared libraries needed by the library. The ldd command can be handy to diagnose the application startup problem. If some program is not starting due to dependencies not available then you can ldd to find out the shared libraries it’s looking for.

netstat

netstat (Network Statistics) is a popular command to print network connections, interface statistics, and to troubleshoot various network-related issue. To show stats of all protocols You can use grep to find out if any errors To show the kernel routing table Explore more netstat command examples.

free

If your Linux server is running out of memory or just want to find out how much memory available out of available memory, then the free command will help you. -g means to show the details in GB. So as you can see total available memory is 5 GB and 3 GB is free.

sar

sar (System Activity Report) will be helpful to collect a number of a report including CPU, Memory, and device load. By just executing sar command will show you system utilization for the entire day.

By default, it stores utilization report in 10 minutes. If you need something shorter in real-time, you can use it as below. Show CPU report for 3 times every 3 seconds Show Memory usage report Show network report

ipcs

ipcs (InterProcess Communication System) provides a report on the semaphore, shared memory & message queue. To list the message queue To list the semaphores To list the shared memory To display the current usage status of IPC

ioping

ioping is an external command you can install it from here. It can be very handy to monitor the disk I/O latency in real-time.

Conclusion

I hope the above commands help in the various situation at your system administration job. The above-mentioned commands are good to use on-demand. However, if you need to monitor Linux servers all the time then you should consider using server monitoring software. And, to learn more about Linux performance, you can check out this Udemy course.

12 Linux Performance Commands to Know as a System Administrator - 612 Linux Performance Commands to Know as a System Administrator - 8612 Linux Performance Commands to Know as a System Administrator - 7312 Linux Performance Commands to Know as a System Administrator - 9712 Linux Performance Commands to Know as a System Administrator - 9312 Linux Performance Commands to Know as a System Administrator - 9612 Linux Performance Commands to Know as a System Administrator - 3912 Linux Performance Commands to Know as a System Administrator - 6012 Linux Performance Commands to Know as a System Administrator - 9812 Linux Performance Commands to Know as a System Administrator - 4712 Linux Performance Commands to Know as a System Administrator - 3712 Linux Performance Commands to Know as a System Administrator - 5112 Linux Performance Commands to Know as a System Administrator - 3312 Linux Performance Commands to Know as a System Administrator - 1212 Linux Performance Commands to Know as a System Administrator - 9012 Linux Performance Commands to Know as a System Administrator - 912 Linux Performance Commands to Know as a System Administrator - 7312 Linux Performance Commands to Know as a System Administrator - 1512 Linux Performance Commands to Know as a System Administrator - 7012 Linux Performance Commands to Know as a System Administrator - 5712 Linux Performance Commands to Know as a System Administrator - 2012 Linux Performance Commands to Know as a System Administrator - 1512 Linux Performance Commands to Know as a System Administrator - 4912 Linux Performance Commands to Know as a System Administrator - 74