Linux Commands to Troubleshoot Performance Issues

Posted by

When troubleshooting Linux systems, it’s common practice to use a range of commands to obtain details about the hardware, processes, and resource utilisation of the system. The following popular Linux commands can be used to diagnose problems with performance:

top: Shows a live view of the resources used by system processes. To sort processes by memory utilisation, press Shift + M; to sort by CPU usage, press Shift + P.

htop: An interactive process viewer that offers the top command a more feature-rich and user-friendly substitute.

vmstat: Provides real-time information about CPU activity, memory, paging, block IO, traps, and processes.

vmstat 1 5   # Display 5 samples with 1-second intervals

iostat: Reports CPU utilization and I/O statistics for devices, partitions, and network filesystems.

iostat -x 1 5   # Display extended statistics for 5 samples with 1-second intervals

free: Displays the amount of free and used memory in the system.

sar: Collects, reports, or saves system activity information. It is useful for monitoring CPU, memory, and disk activity over time.

ps: Reports a snapshot of the current processes.

ps aux | grep <process_name>   # Display information about a specific process

netstat: Displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.

netstat -tulpn   # Display listening ports and associated processes

lsof: Lists open files and the processes that opened them.

lsof -i :<port_number>   # Display processes using a specific port

dmesg: Displays the kernel ring buffer, which contains information about the system’s hardware and events.

uptime: Displays how long the system has been running, the number of users, and the load average.

tcpdump: Captures and displays packets on a network interface.

tcpdump -i <interface_name>   # Capture packets on a specific network interface
tcpdump -i <interface_name>   # Capture packets on a specific network interface

For Linux systems, these commands can yield useful information for identifying and resolving performance problems. Combining different commands can be helpful in gaining a complete picture of the system’s functioning.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x