Linux top command
Linux top is a real-time system monitoring tool commonly used on Linux and other Unix-like systems. It provides a dynamic, interactive real-time view showing overall system performance information and information about running processes.
Permissions required: all users.
Syntax
top [-] [d delay] [q] [c] [S] [s] [i] [n] [b]
Parameter Description:
-d <秒数>: Specify the refresh interval of the top command, in seconds.-n <次数>: Specify the number of times the top command runs before exiting automatically.-p <进程ID>: Display information only for the specified process ID.-u <用户名>: Display information only for processes of the specified username.-H: Display detailed thread information in the process information.-i: Do not display idle or useless processes.-b: Run in batch mode, outputting results directly to a file.-c: Display the full command line without truncation.-S: Display the cumulative CPU usage time of processes.
Display information
Some common features and displayed information of the top command:

Overall system information:
- uptime: the system's running time and average load.
- tasks: the number of currently running processes and threads.
- CPU: overall CPU usage and the usage of each core.
- Memory: overall memory usage, available memory, and cache.
Process information:
- PID: the process identifier.
- USER: the username running the process.
- PR (priority): the priority of the process.
- NI (Nice value): the priority adjustment value of the process.
- VIRT (virtual memory): the size of virtual memory used by the process.
- RES (resident memory): the size of physical memory actually used by the process.
- SHR (shared memory): the size of memory shared by the process.
- %CPU: the CPU usage rate of the process.
- %MEM: the memory usage rate of the process.
- TIME+: the cumulative CPU time of the process.
Features and interactive operations:
- Key commands: while top is running, you can use some key commands, such as pressing "k" to terminate a process or "h" to display help information.
- Sorting: you can sort processes by CPU usage, memory usage, process ID, and so on.
- Refresh rate: you can set the refresh rate of top to dynamically view system information.
Example
Display process information
# top
Display the full command
# top -c
Display program information in batch mode
# top -b
Display program information in cumulative mode
# top -S
Set the number of information updates
top -n 2
// indicates termination of update display after two updates
Set the information update time
# top -d 3
// indicates the update cycle is 3 seconds
Display information for a specified process
# top -p 139
//Display process information for process ID 139, such as CPU and memory usage
Exit after ten updates
top -n 10
The user will not be able to use interactive commands to issue commands to processes
top -s
Linux Command Reference