Monitoring system performance is crucial for maintaining a healthy Linux server. The top
and htop
commands are two powerful tools for checking real-time system resource usage, including CPU, memory, disk, and process statistics. Here’s how to use both tools to monitor your system performance.
top
Commandtop
CommandThe top
command shows a dynamic, real-time view of the system’s processes, CPU usage, memory usage, and more.
top
top
OutputThe top command displays several key metrics:
Press Shift + P
to sort processes by CPU usage or Shift + M
to sort by memory usage.
If you want to terminate a process, press k
and then enter the PID of the process you wish to kill.
top
Press q
to exit top
.
htop
Commandhtop
If htop
is not already installed, you can install it with the following command:
sudo apt install htop
htop
CommandTo launch htop
, simply type:
htop
htop
Outputhtop
provides a more user-friendly, colorful interface that displays the same information as top
, but with additional features:
You can sort processes by CPU or memory usage by clicking on the respective column headers or by pressing F6
and selecting the column to sort by.
To kill or send signals to a process, select the process and press F9
to choose a signal to send, such as SIGKILL
.
htop
To exit htop
, press F10
or q
.
top
for quick, real-time monitoring of system performance via the command line. htop
for a more user-friendly, visually appealing interface with additional features like filtering, sorting, and easier process management.By mastering these tools, you can keep track of your Linux server’s performance and quickly identify any resource-heavy processes or bottlenecks.