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

How to use top command in Linux system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to use the top command in the Linux system", the content is easy to understand, clear, hope to help you solve your doubts, let the editor lead you to study and learn "how to use the top command in the Linux system" this article.

The top command is often used to monitor the system status of linux, such as the use of cpu and memory. Programmers basically know this command.

How to use top:

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 Line 1 is the task queue information, with the following parameters:

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: 159 total, 1 running, 158 sleeping, 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 2nd and 3rd behavior processes and CPU information

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

Show details

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:

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

II. Process information

Show details

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+".

4. Change the process display field

In the top base view, click "f" to enter another view, where you can edit the display fields in the base view:

Use the up and down keys to select an option, and press the spacebar to decide whether to display this option in the base view.

The top command is a very powerful feature, but the smallest unit it monitors is the process. If you want to monitor smaller units, you need to use the ps or netstate command to meet our requirements.

The above is all the contents of the article "how to use top commands in Linux system". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report