Linux top and free commands) and top commands

Source: Internet
Author: User

Linux top and free commands (to) and top commands

Link:

 

Top: The command monitors the status of the system processor in real time. It displays the list of the most "sensitive" CPU tasks in the system.

This command sorts tasks by CPU usage, memory usage, and execution time;

In addition, many features of this command can be set through interactive commands or in a custom file.

Top-01:06:48 up, 1 user, load average: 0.06, 0.60, 0.48

Tasks: 29 total, 1 running, 28 sleeping, 0 stopped, 0 zombie

Cpu (s): 0.3% us, 1.0% sy, 0.0% ni, 98.7% id, 0.0% wa, 0.0% hi, 0.0% si

Mem: 191272 k total, 173656 k used, 17616 k free, 22052 k buffers

Swap: 192772 k total, 0 k used, 192772 k free, 123988 k cached

 

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

1379 root 16 0 7976 2456 S 1980 0.7. 03 sshd

14704 root 16 0 2128 980 R 796 0.7. 72 top

1 root 16 0 1992 632 S 544 0.0. 90 init

2 root 34 19 0 0 S 0.0 0.0. 00 ksoftirqd/0

3 root RT 0 0 0 S 0.0 0.0. 00 watchdog/0

 

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 the running duration of the system from startup to the present. Unit: 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

CPU usage of 0.0% hi Hardware interrupt (Hardware IRQ)

0.0% CPU usage of si Soft Interrupt (Software Interrupts)

 

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.

 

 

The free command is used to display memory usage.

 

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.

 

After using this command, the memory continuously reports memory usage (in bytes) and updates every 5 seconds.

# Free-B-s5

 

Total used free shared buffers cached

Mem: 3266180 3250004 16176 0 110652 2668236

-/+ Buffers/cache: 471116 2795064

Swap: 2048276 80160 1968116

 

Total: total physical memory size.

Used: used.

Free: available.

Shared: The total memory Shared by multiple processes.

Buffers/cached: disk cache size.

 

Row 3 (-/+ buffers/cached ):

Used: used.

Free: available.

The fourth line won't be explained much.

Difference: used/free of the second row (mem) differs from used/free of the third row (-/+ buffers/cache. The difference between the two is that,

The first line is from the OS perspective, because for OS, buffers/cached is used, so its available memory is 16176KB, And the used memory is 3250004KB, including, + buffers + cached used by the kernel (OS) + Application (X, oracle, etc.

The third line indicates that, from the application perspective, for applications, buffers/cached is equivalent to available, because buffer/cached is designed to improve file read performance, when the application needs to use the memory, buffer/cached will be quickly recycled.

From the application perspective, the available memory = system free memory + buffers + cached.

For example:

2795064 = 16176 + 110652 + 2668236

 

Next, we will explain when the memory will be exchanged and by which side. When the available memory is less than the rated value, a meeting will be held for exchange.

 

Memory usage Measurement

 

Measure how much memory a process occupies. linux provides us with a very convenient method. The/proc Directory provides us with all the information, in fact, the top tool also obtains the corresponding information here.

 

/Proc/meminfo memory usage information of the machine

 

/Proc/pid/maps pid is the process number and displays the virtual address occupied by the current process.

 

Memory occupied by/proc/pid/statm Process

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.