top (Table of Processes)
The top command provides a dynamic, real-time view of a running system. It displays system summary information as well as a list of processes currently being managed by the Linux kernel. It is the most widely available monitoring tool on any Unix-like system.
1. How to Run
top
2. Understanding the Summary Area
- uptime: Current time, how long the system has been running, and number of users.
- load average: System load for the last 1, 5, and 15 minutes.
- Tasks: Count of processes in running, sleeping, stopped, or zombie states.
- %Cpu(s): CPU utilization broken down by user (us), system (sy), idle (id), etc.
- KiB Mem / Swap: Total, used, and free space for physical RAM and Swap area.
3. Essential Interactive Commands
| Key | Function | Description |
|---|---|---|
| h | Help | Shows a summary of all interactive commands. |
| q | Quit | Exits the top program. |
| k | Kill | Allows you to terminate a process by entering its PID. |
| M | Sort by Memory | Sorts the process list by memory usage (resident set size). |
| P | Sort by CPU | Sorts the process list by CPU percentage (default). |
| 1 | Multi-Core View | Toggles between combined CPU stats and individual core stats. |
| z | Color Toggle | Highlights running processes or adds color to the display. |
4. [Tip] Monitoring a Specific Process
If you want to monitor only a specific Process ID (PID), use the -p flag:
top -p 1234