top
Display Linux processes (dynamic)
Overview
Provides a dynamic real-time view of a running system, displaying a list of the most CPU-intensive tasks and system summary information.
Syntax
top [OPTION]...Common Options
-d delay, --delay=delaySpecify the delay between screen updates (e.g., -d 5 for 5 seconds).
-n iterations, --iterations=iterationsSpecify the maximum number of iterations top should produce before ending.
-p pidlist, --pid=pidlistMonitor only processes with specified process IDs (e.g., -p 123,456).
-u username, --user=usernameMonitor only processes owned by the specified user.
-b, --batchBatch mode operation. Useful for sending output from top to other programs or to a file.
-i, --ignore-idleIdle process toggle. If Off, tasks that haven't used CPU since the last update aren't displayed.
-c, --command-lineCommand line/Program name toggle. Toggles between showing the command line and the program name when invoking top.
Interactive Commands
| Key | Action |
|---|---|
| h or ? | Display help screen. |
| q | Quit top. |
| k | Kill a process (prompts for PID and signal). |
| r | Renice a process (prompts for PID and nice value). |
| P (Shift+p) | Sort by CPU usage (default). |
| M (Shift+m) | Sort by Memory usage. |
| T (Shift+t) | Sort by Time/Cumulative time. |
| N (Shift+n) | Sort by PID. |
| u | Filter by user (prompts for username). |
| 1 | Toggle display of individual CPU states (for multi-core systems). |
| c | Toggle display of command name or full command line (interactive). |
| z | Toggle color/mono display. |
| W (Shift+w) | Write current configuration to ~/.toprc. |
| d or s | Change update delay (prompts for new delay). |
Examples
Starts top with default settings, interactive mode.
Starts top, refreshing every 2 seconds.
Runs top for 5 iterations in batch mode, saving output to top_output.txt.
Shows only processes owned by myuser.
Monitors only PIDs 1234 and 5678.
Starts top, showing full command lines.
Sorts processes by memory usage.
Kills a specified process.