To monitor system performance in Linux, you can use various command-line tools that provide insights into CPU, memory, disk, and network usage. Here are some commonly used tools and commands:
1. top
Displays real-time information about system processes, including CPU and memory usage.
top
2. htop
An enhanced version of top with a more user-friendly interface. You may need to install it first.
htop
3. vmstat
Provides information about processes, memory, paging, block I/O, traps, and CPU activity.
vmstat 1 5 # Displays stats every second for 5 seconds
4. iostat
Monitors CPU and I/O statistics for devices and partitions.
iostat -x 1 # Displays extended I/O stats every second
5. free
Displays memory usage, including total, used, free, and swap memory.
free -h # Displays memory in a human-readable format
6. sar
Collects and reports system activity information, including CPU, memory, and I/O statistics.
sar -u 1 5 # Displays CPU usage every second for 5 seconds
7. netstat or ss
Monitors network connections and statistics.
netstat -tuln # Displays active listening ports
ss -tuln # A modern alternative to netstat
8. df
Displays disk space usage for file systems.
df -h # Displays disk usage in a human-readable format
9. du
Shows disk usage for specific directories or files.
du -sh /path/to/directory # Displays total size of the specified directory
10. nload
A real-time network traffic monitor that shows incoming and outgoing traffic.
nload
11. glances
A comprehensive monitoring tool that provides a summary of various system metrics. You may need to install it first.
glances
These tools can help you effectively monitor system performance, identify bottlenecks, and troubleshoot issues in a Linux environment.
