Catalog / Process Monitoring with `top` and `htop`
Process Monitoring with `top` and `htop`
A cheat sheet for monitoring system processes using `top` and `htop` utilities, covering essential commands and options for effective system administration.
Basic `top` Usage
Overview
|
To start
|
Press |
Interactive Commands
|
Display help summary. |
|
Kill a process. You’ll be prompted for the PID and signal (default is 15, SIGTERM). |
|
Toggle display of idle processes. Shows/hides processes that aren’t using CPU. |
|
Show CPU usage per core (multiple CPUs). |
|
Sort processes by memory usage. |
|
Sort processes by CPU usage (default). |
Command-line Options
|
Specify delay between updates in seconds. |
|
Specify the number of iterations before |
|
Show only processes for the specified username. |
|
Monitor only the specified process ID. |
Advanced `top` Features
Field Descriptions
PID: Process ID. |
Customizing the Display
|
Field Management: Add/remove/reorder fields displayed. |
|
Change the order of the displayed fields. (Not available on all versions.) |
|
Write current configuration to |
Understanding Load Averages
The load average (displayed at the top) shows the average number of processes that are either runnable or uninterruptible. |
A load average of 1.0 means the system is fully utilized by one process per core. Higher values indicate overload. |
Basic `htop` Usage
Introduction to `htop`
|
If
To start
|
Press |
Keybindings
|
Help screen. |
|
Setup: Configure |
|
Search for a process by name. |
|
Filter processes. |
|
Tree view (shows parent-child relationships between processes). |
|
Sort processes by a column (CPU, MEM, etc.). |
|
Change process priority (nice value). |
|
Kill a process. |
Understanding `htop` Display
|
Processes are listed with color-coded information, making it easier to identify resource-intensive processes. |
Advanced `htop` Configuration
Customizing `htop`
Press |
|
Filtering Processes
Press |
Enter a string to filter processes whose command lines contain that string. |
Tree View
Press |
This view is helpful for identifying processes spawned by other processes. |