The top command in Linux is detailed __linux

Source: Internet
Author: User
the top command in Linux is detailed Introduction

The top command is the first entry into the Unix/linux system for viewing the details of the system, and when we look at the state of the machine, it's always the first one to use the top command, and in fact the top command shows a lot of data, which is actually not friendly to the novice. The main purpose of this paper is to do a detailed comb. Introduction (description)

The top program provides a display of real-time data for a running system. It can show the basic information about the system and the tasks currently being managed by the Linux kernel. The types of summary information for these systems and the types of task presentations, sorting and sizing, are user configurable, and these configurations can be persisted and unaffected by the restart. First Line/basic information

The first line can be replaced with the command uptime. The first line of content is displayed from left to right, respectively
* Current Time
* Cumulative and running time of the system
* Number of users currently logged in
* Current system load. system load three digits of meaning

In general, every 5 seconds the system checks the number of processes active in the current system. This active process must meet 3 prerequisites
* It's not waiting for I/O operation results
* It does not actively enter the waiting state (that is, it does not call ' wait ')
* Not stopped (for example: waiting to terminate)
The three values of the system load represent the average of 1 minutes, 5 minutes, and 15 minutes of system load.
For a system with N-core processors, when the load of the system is average to N, the system is almost just full load, but there is no additional experience to deal with other tasks. When the load average is greater than N, the system is overloaded. In general, to enable the system to function normally, we experience that task load average/n < 0.7 is generally acceptable. Second line/cpu information


The second line mainly displays the process and CPU information, noting that the task refers to the process in the top command. The second line of information is
* Total number of processes
* Number of processes running normally
* Total number of dormant processes
* Total number of processes stopped
* Total Zombie Process
* The percentage of the US user process consuming CPU resources
* SY kernel process as a percentage of CPU resources
* NI% of CPU resources for processes that have changed priority within the user process space
* Percent of free CPU for ID
* The percentage of CPU resources that the process of WA waits for input and output
*% of hi hard interrupt usage
*% of SI soft interrupt occupancy
* St Virtual machine occupancy percentage third line/memory related information

Amount of physical memory used by mem Total total amount of free physical memory used in total amount of total memory swap area total free swap area amount of swap zone volume

Swap: Represents the use of swap partitions on the hard disk. Only the mem is actually occupied by the current process, that is, when there is no buffers and cache, then swap is used.

The above sentence is only the ideal state of the general situation, in fact, the kernel may take the initiative to write some temporarily unused memory block to the disk swap area (swap), so that the saved memory can be used as he used. The memory that is written to swap is rewritten to memory only when it is actually needed.
Note: When physical memory is idle, there may be a lot of swap. The reason is that there is a possibility that a process that requires a large amount of physical memory, and when the process ends, the process is swapped into swap memory during the lifecycle, and is not released voluntarily. The operating system is always in the actual need to do processing, which will appear in a certain period of time, physical memory is very idle, and swap usage is very high. Process Information

Refer to the description of top in Linux
* pid:process ID Process ID, which is the unique identifier for the process. This ID is periodically overwritten, but will not start at 0.
* ppid:parent process PID parent Processes PID
* Ruser:real user name, current process true username
* Uid:user ID. Valid user ID of the process owner
* User:user Name, effective username
* Group:group name user Group populist
* The name of the Tty:controlling TTY control terminal. The terminal name of the startup process. However, when a process is not accessed from the terminal, you will see the question mark (...). )
* Pr:priority Process Priority
* Ni:nice value. Priority values, negative numbers indicate high precedence, and positive numbers indicate lower precedence.
* P:last UserD CPU (SMP). In a multiple-processing environment, represents the most recent CPU ordinal used.
* Percentage of total CPU time used by%CPU:CPU
* Time:cpu time task from the start to the current use of the total length of the CPU.
* Time +: CPU time, hundredths more granular and more accurate CPU time consuming
*%mes: The amount of memory used by the process
* Virt: The size of the virtual memory used by the process
* Swap: The size of the swap area used by the process
* Res:resident size resides in memory, which means that the process drops the memory that uses swap swap and the size of the physical memory used
* Code:code size refers to the amount of physical memory the code occupies
* data:data + stack size data and heap footprint
* The size of the shr:shared Mem size process Shared memory
* Nflt:page Fault Count page number of pages
* Ndrt:dirty pages Count Dirty page quantity
* s:process status process state. There are D R S T Z, respectively, which means "interruptible sleep" "Running" "Suspend or Trace State" "Zombie state", reference
* Command:command line or program name command or process name
* Wchan:sleep in function to show currently dormant functions
* The standard of the Flages:task Flags process in process planning.

The difference between Ruser and user
has three users in Linux: Real user,effection user, Saved-set user.
If you run a program that executes as root, then the effective user of this program is root. For Saved-set user, more complex I am not very understand, I found two pieces of information, you can refer to, Welcome to Exchange reference 1 reference 2

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.