Top is a dynamic display process. You can press the buttons to refresh the current status. if you execute this command on the foreground, it excludes the foreground until the user terminates the program. more accurately, the top command provides real-time monitoring of the status of the system processor. it displays the list of CPU-sensitive tasks in the system. this command can be used by CPU. the memory usage and execution time are used to sort tasks. Many features of this command can be set through interactive commands or in a custom file.
Top-11:17:54 up 230 days, 2 users, load average: 0.00, 0.00, 0.00
Task: 276 total, 1 running, 275 sleeping, 0 stopped, 0 zombie
CPU (s): 0.1% us, 0.1% Sy, 0.0% Ni, 99.7% ID, 0.0% wa, 0.0% hi, 0.0% Si, 0.0% St
Mem: 32883788 k total, 19153696 K used, 13730092 K free, 624472 K Buffers
Swap: 22727672 k total, 265432 K used, 22462240 K free, 6998112 K cached
PID user PR Ni virt res shr s % CPU % mem time + command
4114 resin_su 20 0 5432 M 362 m 11 m s 0.3 1.1 82: 21.85 Java
5083 resin_op 20 0 97808 1808 880 s 0.3 0: 00. 01 sshd
The first line:
10:01:23 current system time
126 days, the system has been running for 126 days, 14 hours, and 29 minutes (during this period, the system has not restarted)
2 users currently has two users logging on to the system
Load average: 1.15, 1.42, and 1.44 load average are the loads of 1 minute, 5 minutes, and 15 minutes respectively.
The load average data checks the number of active processes every five seconds and then calculates the value based on a specific algorithm. If this number is divided by the number of logical CPUs, the system is overloaded when the result is higher than 5.
Row 2:
Task tasks (processes), the system now has a total of 183 processes, of which one is running, 182 are sleep, and 0 are stoped, zombie status (zombie) has 0.
Row 3: CPU status
6.7% us CPU usage percentage.
0.4% percentage of CPU occupied by Sy kernel space.
0.0% percentage of CPU used by processes whose priorities have changed by Ni
92.9% ID idle CPU percentage
0.0% percentage of CPU occupied by wa Io wait
CPU usage of 0.0% Hi hardware interrupt (hardware IRQ)
0.0% CPU usage of Si Soft Interrupt (software interrupts)
Here, the CPU usage rate is different from that of windows. If you do not understand the user space and kernel space, you need to recharge your instance.
Row 4: memory status
8306544 k total physical memory (8 GB)
Total memory used by 7775876 K used (7.7 GB)
530668 K free memory (530 MB)
79236 K buffers cache memory (79 m)
Row 5: swap Partition
2031608 k total swap zone total (2 GB)
Total number of swap areas used by 2556 K used (2.5 m)
2029052 K free swap zone total (2 GB)
4231276 K cached buffer swap zone (4 GB)
It should be noted that the concept of memory in Windows cannot be used to understand the data. If the server is vulnerable in Windows mode, the total memory size of 8 GB is limited to MB of available memory. Linux memory management has its own particularity. The complexity needs to be explained in a book. Here is just a simple description of the difference from our traditional concept of windows.
In Row 4, the total memory used (used) refers to the number of memories currently controlled by the system kernel. The total idle memory (free) is the amount of memory that the kernel has not yet incorporated into its control scope. The memory included in the kernel management is not always in use, but also the memory that can be reused in the past, the kernel does not return the reusable memory to free. Therefore, free memory will become fewer and fewer on Linux, but you don't have to worry about it.
If you calculate the number of available memory out of habit, there is an approximate formula: free in the fourth row + buffers in the fourth row + cached in the fifth row, according to this formula, the available memory of this server is 530668 + 79236 + 4231276 = 4.7 GB.
For memory monitoring, we need to monitor the used of the fifth-line swap partition in top. If this value is constantly changing, it means that the kernel is constantly exchanging data between memory and swap, this is the real insufficient memory.
Row 6 is empty
Line 7: Status monitoring of processes (tasks)
PID process ID
User process owner
PR process priority
Ni nice value. A negative value indicates a high priority, and a positive value indicates a low priority.
Total virtual memory used by the virt process, in KB. Virt = swap + Res
The size of the physical memory used by the res process, Not swapped out, in KB. Res = code + Data
Size of SHR shared memory, in KB
S Process status. D = non-disruptive sleep state R = running S = sleep T = tracking/stopping z = botnets
% Percentage of CPU time used since the last CPU update to the present
% Mem percentage of physical memory used by the Process
Time + total CPU time used by the process, in the unit of 1/100 seconds
Command process name (command name/command line)
In the top basic view
Press the number 1 on the keyboard to monitor the status of each logical CPU;
Press keyboard B to highlight the current running process;
Press X on the keyboard to highlight the current sorting column;
Shift +> or SHIFT + <can be used to change the sorting column to the right or left;
Press the f key and top to enter another view. Here, you can orchestrate the display fields in the basic view;
Display content control
Top [-] [d] [p] [Q] [C] [C] [s] [N]
Parameter description:
D: Specifies the interval between two screen information refreshes. Of course, you can use the S interactive command to change it.
P: only the status of a process is monitored by specifying the monitoring process ID.
Q: This option will refresh top without any delay. If the caller has the superuser permission, top runs with the highest possible priority.
S: indicates the accumulative mode.
S: run the TOP Command in safe mode. This removes the potential danger of interactive commands.
I: no idle or dead processes are displayed on top.
C: display the entire command line, not just the command name
In the top command display window, you can enter the following letters for interaction:
Iii. Instances