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 View system Resource occupancy under Linux

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

Share

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

This article mainly introduces how to view the occupation of system resources under Linux, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.

1. View the total memory footprint

Command: free

Figure 1 free command to view memory footprint

(1) the free command is displayed in kb units by default, and can be displayed in Mb units with free-m.

(2) Mem line: total = used + free where buffers and cached are calculated in used, but they are actually available memory.

(3) the next line of Mem: used is the real occupied memory and free is the real available memory.

(4) Swap: usage of memory swap area.

2. View the top five memory-consuming processes

Command: ps auxw | head-1: PS auxw | sort-rn-K4 | head-5

Figure 2.1 View the processes in the top 5 memory footprint

As shown in figure 2.1, the unit of memory is kb,VSZ, which is the footprint of virtual memory, and RSS, which is the footprint of real memory.

Command decomposition:

Ps auxw displays the system resource usage

Head-1 indicates that the first column, the title column, is displayed

Sort-r indicates reverse sorting,-n indicates sorting by number, and-K4 represents the fourth character of the column.

3. View the top three processes occupied by CPU

Command: ps auxw | head-1: PS auxw | sort-rn-K3 | head-3

Figure 3.1 View the top three processes occupied by cpu

This command is similar to figure 2.1, except that the third column of the selected resource usage (that is, cpu) is represented by "- K3".

4. View the overall load of the system

Command: top

Figure 4.1 top shows the overall load of the system

(1) the first line: system time + system run time + several users + 1-5-15 minutes average system load

(2) second line: total processes (total) + running processes (running) + sleep processes (sleeping) + stopped processes (stopped) + zombie processes (zombie)

(3) third line: user space CPU percentage (us) + kernel space CPU percentage (sy) + CPU vacancy rate (id)

Blob.png

Figure 4.2 Resource consumption of each task

Notes:

PID: process ID

USER: user name

PR: priority

NI: negative values indicate high priority and positive values indicate low priority.

VIRT: virtual memory

RES: real memory

SHR: shared memory

S: process state D = uninterruptible sleep state; R = run; S = sleep; T = track / stop; Z = zombie process

Parameters:

Top-d 2: explicit resource usage of all processes every 2 seconds

Top-c: show the resource consumption of the process every 5 seconds and display the process's command line arguments (only the process name is the default)

Top-p 12345-p 6789: shows the resource utilization of two processes with pid of 12345 and pid of 6789 every 5 seconds

Top-d 2-c-p 123456: displays the resource usage of a process whose pid is 12345 every 2 seconds, and explicitly shows the command line parameters started by the process

Thank you for reading this article carefully. I hope the article "how to check the usage of system resources under Linux" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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