View CPU information in Linux

Source: Internet
Author: User
Article Title: View CPU information in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

The top command is a common performance analysis tool in Linux. It can display the resource usage of various processes in the system in real time, similar to the Windows Task Manager. The following describes how to use it.

Top-02:53:32 up 16 days, 17 users, load average: 0.24, 0.21, 0.24

Tasks: 481 total, 3 running, 474 sleeping, 0 stopped, 4 zombie

Cpu (s): 10.3% us, 1.8% sy, 0.0% ni, 86.6% id, 0.5% wa, 0.2% hi, 0.6% si, 0.0% st

Mem: 4042764 k total, 4001096 k used, 41668 k free, 383536 k buffers

Swap: 2104472 k total, 7900 k used, 2096572 k free, 1557040 k cached

Pid user pr ni virt res shr s % CPU % mem time + COMMAND

32497 jacky 20 0 669 m 222 m 31 m R 10 5.6 29:27. 62 firefox

4788 yiuwing 20 0 257 m 18 m 13 m S 5 0.5. 44 konsole

5657 Liuxiaof 20 0 585 m 159 m 30 m S 4 4.0. 06 firefox

4455 xiefc 20 0 542 m 124 m 30 m R 4 3.1. 03 firefox

6188 Liuxiaof 20 0 191 m 17 m 13 m S 4 0.5. 16 konsole

The first five lines in the statistical information area are the overall statistical information of the system. The first line is the task queue information, which is the same as the execution result of the uptime command. The content is as follows:

01:06:48 current time

Up system running time, format: minute

1 user current Login user count

Load average: 0.06, 0.60, 0.48 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.

Second and Third, information about the process and CPU. When multiple CPUs exist, the content may exceed two rows. The content is as follows:

Tasks: 29 total process count

1. Number of running Processes of running

28 sleeping sleep Processes

0 stopped process count

0 zombie botnets

Cpu (s): 0.3% us CPU usage

1.0% sy CPU usage in kernel space

0.0% percentage of CPU used by processes that have changed their priorities in ni user process space

98.7% id idle CPU percentage

0.0% wa CPU time percentage waiting for Input and Output

0.0% hi

0.0% si

Memory information of the last two behaviors. The content is as follows:

Mem: 191272 k total physical memory

Total physical memory used by 173656 k used

17616 k free Memory Total

Memory usage of 22052 k buffers as kernel Cache

Swap: 192772 k total number of Swap Areas

Total number of swap areas used by 0 k used

192772 k free swap zone total

The total number of swap areas of the 123988 k cached buffer.

The content in the memory is swapped out to the swap zone and then into the memory, but the used swap zone has not been overwritten,

This value indicates the size of the SWAp zone where the content already exists in the memory.

When the corresponding memory is swapped out again, you do not have to write data to the swap zone.

Detailed information about each process is displayed at the bottom of the process information area. First, let's take a look at the meaning of each column.

Serial Number Column name meaning

A PID process id

B PPID parent process id

C RUSER Real user name

D UID: User ID of the process owner

E USER: USER Name of the process owner

GROUP name of the owner of the f GROUP process

The terminal name of the g TTY startup process. Processes not started from the terminal are displayed?

H PR priority

I NI nice value. A negative value indicates a high priority, and a positive value indicates a low priority.

The final CPU used by j P is only meaningful in multiple CPU Environments

K % percentage of CPU time used since the last CPU update to the present

L total cpu time used by the TIME process, in seconds

M TIME + the total cpu time used by the process, in the unit of 1/100 seconds

N % MEM percentage of physical memory used by the Process

O total virtual memory used by the VIRT process, in kb. VIRT = SWAP + RES

The SWAP size in the virtual memory used by the p SWAP process, in kb.

The size of the physical memory used by the q RES process, Not swapped out, in kb. RES = CODE + DATA

The physical memory occupied by the r CODE executable CODE, in kb.

Physical memory occupied by other parts (DATA Segment + stack) except the executable code of s DATA, in kb

T SHR shared memory size, in kb

U nFLT page error count

The number of modified pages that the last write to the present by v.

W S Process status.

D = uninterrupted sleep

R = run

S = sleep

T = tracking/stopping

Z = zombie Process

X COMMAND name/COMMAND line

Y WCHAN: if the process is sleep, the system function name in sleep is displayed.

Z Flags task flag, refer to sched. h

By default, only important PID, USER, PR, NI, VIRT, RES, SHR, S, % CPU, % MEM, TIME +, and COMMAND columns are displayed. You can use the shortcut keys below to change the display content.

You can use the f key to change the display content. Press f to display the column list. Press a-z to display or hide the corresponding column, and press enter to confirm.

Press the o key to change the Column Display sequence. A lower-case a-z can move the corresponding column to the right, while an upper-case A-Z can move the corresponding column to the left. Press enter.

Press the F or O key in upper case, and then press a-z to sort the process according to the corresponding column. The uppercase R key can reverse the current sorting.

====================================

Some interactive commands can be used to complete other parameter functions during the use of the top command. These commands are started by using the shortcut key.

<Space>: refresh immediately.

P: sort by CPU usage.

T: sort by time and accumulated time.

Q: exit the top command.

M: Switch to Display memory information.

T: process and CPU status information is displayed during switchover.

C: Switch the display command name and the complete command line.

M: sort by memory size.

W: Write the current settings ~ /. Toprc file. This is a recommended method for writing top configuration files.

As you can see, the top command is a powerful tool for monitoring the system, especially for system administrators. However, it consumes a lot of system resources.

Application Instance

The top command can be used to monitor the process of a specified user. By default, the process of all users is monitored. If you want to view the situation of a specified user, press the "U" key in the terminal and enter the user name, the system will switch to the process running interface of the specified user.

A. Role

The free command is used to display memory usage. The permission is applied to all users.

B. Format

Free [-B-k-m] [-o] [-s delay] [-t] [-V]

C. Main Parameters

-B-k-m: memory usage is displayed in bytes (KB, MB.

-S delay: the number of seconds to display the memory usage.

-T: displays the total memory column.

-O: the buffer adjustment column is not displayed.

D. Application Instance

The free command is the main command used to view memory usage. Compared with the top command, it is easy to use and only occupies a small amount of system resources. The-S parameter allows you to use the free command to continuously monitor the number of inactive instances. This allows you to use it as a convenient real-time monitor.

# Free-B-s5

With this command, the slave node continuously reports memory usage (in bytes) and updates every 5 seconds.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.