process
top
Interactive real-time view of processes and system resource usage. Refreshes on an interval and supports live sorting and filtering.
top [OPTIONS] Common flags
| Flag | Purpose |
|---|---|
| -b | Batch mode -- output plain text, useful for scripts |
| -n | Exit after N refresh iterations |
| -d | Refresh delay in seconds |
| -p | Monitor only the specified PID(s) |
| -u | Show only processes for the given user |
| -H | Show individual threads |
Examples
top Launch the interactive dashboard
top -b -n 1 > snapshot.txt Capture a single top snapshot for later review
top -u www-data Monitor only the web-server user
top -p $(pgrep -d, nginx) Watch only nginx PIDs
Gotcha
Inside the interactive view, press h for help; press P to sort by CPU or M by memory -- sorting flags on the command line are limited.
Related commands
ps
Snapshots the current process list. Accepts both BSD-style and UNIX-style flags depending on how you want to slice the output.
free
Displays free and used memory including RAM and swap. Reads from /proc/meminfo and summarizes at a glance.
kill
Sends a signal to one or more processes. Defaults to SIGTERM, allowing a process to clean up before exiting.