LinuxCommandLibrary

top

Display and manage running processes

TLDR

Start top

$ top
copy

Do not show any idle or zombie processes
$ top [[-i|--idle-toggle]]
copy

Show only processes owned by given user
$ top [[-u|--filter-only-euser]] [username]
copy

Sort processes by a field
$ top [[-o|--sort-override]] [field_name]
copy

Show the individual threads of a given process
$ top [[-Hp|--threads-show --pid]] [process_id]
copy

Show only the processes with the given PID(s), passed as a comma-separated list. (Normally you wouldn't know PIDs off hand. This example picks the PIDs from the process name)
$ top [[-p|--pid]] $(pgrep [[-d|--delimiter]] ',' [process_name])
copy

Display help about interactive commands
$ <?>
copy

SYNOPSIS

top [options]

PARAMETERS

-d SECS
    Update interval in seconds

-n NUM
    Number of iterations

-p PID
    Monitor specific process

-u USER
    Show processes for user

-b
    Batch mode (for scripting)

-c
    Show command line

-H
    Show threads

-i
    Ignore idle processes

DESCRIPTION

top provides a dynamic real-time view of running processes. It displays system summary information and a list of processes sorted by CPU usage or other criteria. top allows interactive process management and is essential for monitoring system performance.

CAVEATS

High refresh rates increase CPU usage. Default sorting by CPU can be changed. Consider htop for better interface.

INTERACTIVE KEYS

k - Kill process
r - Renice process
M - Sort by memory
P - Sort by CPU
1 - Show per-CPU stats
q - Quit

SEE ALSO

htop(1), ps(1), vmstat(1), atop(1), glances(1)

Copied to clipboard