#top #htop #btop #atop #monitor #linux #debian
### **Monitoring System Performance with `top` and `htop`**
#### **Using `top`**
To start **`top`**, simply run:
`top`
- By default, the list of processes **refreshes every 3 seconds**.
- To change the refresh rate, press **`d`** and enter a new duration in seconds.
---
### **Understanding `top` Output**
| **Column** | **Description** |
| ---------- | ---------------------------------------------------------------------------- |
| **PID** | Process ID |
| **USER** | Owner of the process |
| **PR** | Priority of the process |
| **NI** | "Nice" value (-19 to 20) - Lower values mean higher priority |
| **VIRT** | Virtual memory used |
| **RES** | Physical (resident) memory used |
| **S** | Process state |
| **%CPU** | CPU usage since last update (can go above 100% if multiple cores are in use) |
| **%MEM** | Percentage of physical memory used |
| **TIME+** | Total time the process has been running |
### **Process State (`S`)**
| **Code** | **Meaning** |
| -------- | ------------------------------------------ |
| **R** | Running |
| **S** | Sleeping |
| **D** | Uninterruptible sleep (usually I/O) |
| **Z** | Zombie (process completed but not removed) |
| **T** | Stopped |
| **X** | Dead |
### **Shortcuts in `top`**
| **Key** | **Function** |
| ------- | --------------------------- |
| `q` | Quit `top` |
| `d` | Change refresh interval |
| `k` | Kill a process (enter PID) |
| `r` | Renice (change priority) |
| `f` | Customize displayed columns |
---
## **Using `htop` for Enhanced Process Monitoring**
To start **`htop`**, simply run:
`htop`
#### **Advantages of `htop` Over `top`**
✅ More visual CPU & memory usage graphs
✅ Allows mouse scrolling
✅ Sort columns by clicking
✅ Displays parent/child process trees
✅ Interactive process management (kill, renice, etc.)
---
### **Features of `htop`**
- **CPU Usage**: Displays separate bars for multiple cores.
- **Memory Usage**: Visual representation of used/free memory.
- **Sorting**: Click on any column (PID, CPU, MEM, etc.) to sort.
- **Tree View (`F5`)**: Shows parent/child process relationships.
### **Useful Keyboard Shortcuts in `htop`**
| **Key** | **Function** |
| ------- | ------------------------ |
| `F3` | Search for a process |
| `F4` | Filter processes |
| `F5` | Toggle process tree view |
| `F6` | Sort by column |
| `F9` | Kill a process |
| `F10` | Quit `htop` |
---
### **Example: Viewing the Parent Process Tree**
Press **`F5`** to see the hierarchy of processes.
- The **`/lib/systemd/systemd`** process is always **PID 1**, making it the **first process in Linux**.
🚀 **Now you can effectively monitor and manage system performance with `top` and `htop`!** ✅
[[SNMP, Install and Configure SNMP Monitoring]]
[[Monitor a process in AIX]]