top flags & options
-p
Monitor specific process IDs only.
top -p 1234
top -p 1234,5678
-u
Show only processes owned by a specific user.
top -u www-data
-d
Set the delay between screen updates in seconds.
top -d 0.5
top -d 5
-n
Exit after a specified number of display iterations.
top -n 1
top -bn 3 > top-snapshot.txt
-b
Run in batch mode for scripting or piping output to a file.
top -bn 1 | head -20
-H
Show individual threads instead of just processes.
top -H
top -H -p 1234
Interactive keys
Press these keys while top is running to change the display.
# P - sort by CPU usage
# M - sort by memory usage
# k - kill a process (enter PID)
# c - toggle full command path
# 1 - toggle per-CPU core display
# q - quit