Linux top Command
The Linux top command is used to display real-time dynamic information about processes.
Usage permission: All users.
Syntax
top [-] [d delay] [q] [c] [S] [s] [i] [n] [b]
Parameter Description:
d : Change the display update speed, or press 's' in the interactive command line.
q : Display speed with no delay. If the user has superuser privileges, top will run with the highest priority.
c : Toggle display mode. There are two modes: one shows only the executable file name, and the other shows the full path and name.
S : Cumulative mode, which accumulates the CPU time of completed or disappeared child processes (dead child process).
s : Safe mode, which disables interactive commands to avoid potential risks.
i : Do not show any idle or useless (zombie) processes.
n : Number of updates before exiting top.
b : Batch mode, used in conjunction with the "n" parameter to output top results to a file.
Examples
Display process information
# top
Display full commands
# top -c
Display process information in batch mode
# top -b
Display process information in cumulative mode
# top -S
Set the number of information updates
top -n 2
// Indicates that the update will terminate after two updates
Set the information update time
# top -d 3
// Indicates that the update interval is 3 seconds
Display information about a specific process
# top -p 139
// Displays information about the process with PID 139, including CPU and memory usage
Display and exit after ten updates
top -n 10
Users will not be able to use interactive commands to command processes
top -s