TrumanWong

top

Display or manage running programs

Supplementary instructions

top command can dynamically view the overall operation of the system in real time. It is a practical tool that integrates multi-party information monitoring system performance and operation information. The interactive interface provided by the top command can be managed using hotkeys.

grammar

top(option)

Options

-b: operate in batch mode;
-c: Display the complete treatment command;
-d: screen refresh interval;
-I: Ignore the failure process;
-s: confidentiality mode;
-S: accumulation mode;
-i<time>: set the interval time;
-u<username>: Specify username;
-p<process number>: specifies the process;
-n<number of times>: the number of times displayed in a loop;
-H: Resource usage of all threads.

top interactive command

Some interactive commands that can be used during the execution of the top command. These commands are all single-letter, and some of them may be blocked if the -s option is used on the command line.

h: Display the help screen and give some brief command summary instructions;
k: terminate a process;
i: Ignore idle and zombie processes, this is a switch command;
q: Exit the program;
r: Rearrange the priority of a process;
S: switch to accumulation mode;
s: Change the delay time between two refreshes (unit is s). If there is a decimal, convert it to ms. Enter a value of 0 and the system will refresh continuously. The default value is 5s;
f or F: Add or delete items from the current display;
o or O: Change the order of displayed items;
l: Switch to display average load and startup time information;
m: Switch to display memory information;
t: Switch to display process and CPU status information;
c: Switch to display the command name and complete command line;
M: Sort according to resident memory size;
P: Sort according to CPU usage percentage;
T: Sort based on time/accumulated time;
w: Write the current settings to the ~/.toprc file.

Example

top - 09:44:56 up 16 days, 21:23, 1 user, load average: 9.59, 4.75, 1.92
Tasks: 145 total, 2 running, 143 sleeping, 0 stopped, 0 zombie
Cpu(s): 99.8%us, 0.1%sy, 0.0%ni, 0.2%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 4147888k total, 2493092k used, 1654796k free, 158188k buffers
Swap: 5144568k total, 56k used, 5144512k free, 2013180k cached

explain:

  • top - 09:44:56[current system time],
  • 16 days[The system has been running for 16 days],
  • 1 user[user currently logged in],
  • load average: 9.59, 4.75, 1.92 [system load, that is, the average length of the task queue]
  • Tasks: 145 total[total number of processes],
  • 2 running[number of running processes],
  • 143 sleeping[number of sleeping processes],
  • 0 stopped[number of stopped processes],
  • 0 zombie[number of frozen processes],
  • Cpu(s): 99.8%us[CPU percentage occupied by user space],
  • 0.1%sy[CPU percentage occupied by kernel space],
  • 0.0%ni [CPU percentage occupied by processes that have changed priorities in the user process space],
  • 0.2%id[idle CPU percentage], 0.0%wa[CPU time percentage waiting for input and output],
  • 0.0%hi[],
  • 0.0%st[],
  • Mem: 4147888k total[total physical memory],
  • 2493092k used[total amount of physical memory used],
  • 1654796k free[total free memory],
  • 158188k buffers [amount of memory used as kernel cache]
  • Swap: 5144568k total[total amount of swap area],
  • 56k used[total amount of swap area used],
  • 5144512k free [total free swap area],
  • 2013180k cached[total buffered swap area],