Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the top command parameters in Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail what are the parameters of the top command in Linux. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Top command usage

Top command is often used to monitor the system status of linux. It is a commonly used performance analysis tool, which can display the resource consumption of each process in the system in real time.

How top is used: top [- d number] | top [- bnp]

Parameter explanation:

-d:number represents the number of seconds and represents the interval between updates to the page displayed by the top command. The default is 5 seconds. -b: execute top in batches. -n: used with-b to indicate the output of the top command several times is required. -p: specify a specific pid process number for observation.

On the page displayed by the top command, you can also enter the following keys to perform the corresponding function (note that it is case sensitive):

: display the commands that can be entered in top P: in CPU usage resource sort M: in memory usage resource sort display N: in pid sort T: the cumulative sort of time used by the process shows k: give a signal to a pid. Can be used to kill the process r: re-customize a nice value (that is, priority) for a pid Q: exit top (you can also exit top with ctrl+c).

The meaning of the output parameters of top

The following is a screenshot of performance testing using the top command:

Figure 1 (ubuntu):

Figure 2 (centos):

First, the first five lines of top statistics

Line 1: top-05:43:27 up 4:52, 2 users, load average: 0.58,0.41,0.30

The first line is the task queue information, whose parameters are as follows:

Content meaning 05:43:27 indicates the current time up 4:52 system runtime format is hours: 2 users number of currently logged-in users load average: 0.58,0.41, 0.30 system load, that is, the average length of the task queue. The three values are the average values from 1 minute, 5 minutes and 15 minutes ago to the present.

Load average: if this number is divided by the number of logical CPU, a result above 5 indicates that the system is overloaded.

Line 2: Tasks: 159total, 1 running, 158sleeping, 0 stopped, 0 zombie

Line 3:% Cpu (s): 37.0 us, 3.7 sy, 0.0 ni, 59.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

Information on the 2nd and 3rd behavior processes and CPU

When there is more than one CPU, these may be more than two lines, with the following parameters:

Content meaning: 159Total total processes 1 running running processes 158processes sleeping 0 stopped stopped processes 0 zombie Zombie processes 0 zombie Zombie processes 37.0 us user Space 3.7sy Kernel Space CPU percentage 0.0 ni user process Space priority changed processes take up CPU% 59.3 id Idle CPU% 0.0 wa waiting for input and output CPU % between 0.0 hi hard interrupt (Hardware IRQ) percentage of CPU occupied 0.0 si soft interrupt (Software Interrupts) percentage of CPU occupied 0.0 st

Line 4: KiB Mem: 1530752 total, 1481968 used, 48784 free, 70988 buffers

Line 5: KiB Swap: 3905532 total, 267544 used, 3637988 free. 617312 cached Mem

4th and 5th behavior memory information

The parameters are as follows:

Content meaning KiB Mem: 1530752 total total physical memory total 1481968 used total physical memory used 48784 free total free memory 70988 buffers (buff/cache) total memory used as kernel cache KiB Swap: 3905532 total total swap total 267544 used total swap total 3637988 free total free swap total 617312 cached Mem buffer total swap. 3156100 avail Mem represents the amount of physical memory available for the next allocation of the process

The total amount of buffered swap areas mentioned above is explained here, that is, the total amount of buffered swap areas, that is, the contents of the memory are swapped out to the swap area, and then swapped into memory, but the used swap area has not been overwritten. This value is the size of the swap area in which these contents already exist in memory. When the corresponding memory is swapped out again, there is no need to write to the swap area.

There is an approximate formula for calculating the number of available memory:

Free of line 4 + buffers of line 4 + cached of line 5

Second, process information column name means PID process idPPID parent process idRUSERReal user nameUID process owner user name idUSER process owner user name GROUP process owner group name TTY startup process terminal name. Processes that are not started from the terminal are displayed as the? PR priority NInice value. A negative value indicates a high priority, and a positive value indicates the last CPU used by the low priority P, meaningful only in a multi-CPU environment.% CPU last updated to the present percentage of CPU time used by the TIME process, total CPU time used by the TIME process, total CPU time used by the TIME+ process in 1 second, 100 seconds% physical memory used by the MEM process, total virtual memory used by the VIRT process, in kb. The amount of virtual memory used by the VIRT=SWAP+RESSWAP process, the amount of physical memory used by the kbRES process and not swapped out, in kb. The amount of physical memory occupied by RES=CODE+DATACODE executable code, the amount of physical memory occupied by parts other than kbDATA executable code (data segment + stack), the size of kbSHR shared memory per unit, the number of errors per kbnFLT page nDRT last written to now, the number of pages that have been modified. S process status. D = uninterruptible sleep state R = run S = sleep T = track / stop Z = zombie process COMMAND command name / command line WCHAN if the process is sleeping, display the system function name in sleep Flags task flag other

When entering top by default, each process is sorted according to the occupancy of CPU.

1. In the top base view, press the keyboard number "1" to monitor the status of each logical CPU:

2. Tap the keyboard'b'(turn on / off the highlighting effect) the top view is transformed as follows:

A PID of 16283 is the only running process in the current top view. You can also tap the keyboard'y'to turn on or off the highlighting effect of the running process.

3. Tap the keyboard'x' (turn on / off the highlighting effect of the sorting sequence), and the top view is transformed as follows:

You can see that it is now sorted by "% CPU". You can press "shift+ >" or "shift+".

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report