Brief analysis of Linux process management commands

Source: Internet
Author: User


On Linux, everything is file. Similarly, the system's real-time status information is also stored on the file system in the form of a file. In/proc/, the state information in the kernel is saved, and the information of the process is saved in the/proc/#中 (#为PID), and we can manage the process of the system by invoking the tool to view the information saved in these files. This time, the analysis of the command has top, htop, Dstat and PS a total of 4 commands.


First, the use of the top command

View the real-time status of the system process. Its format is

Top [D|b|n]

-D #: Specifies the refresh interval, which defaults to 3 seconds

-B: Displayed in batch mode

-N #: Shows how many batches

~]# Top

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M00/78/7F/wKioL1Z-V7DREmusAAPLj0rf_To261.jpg "title=" 1.jpg " alt= "Wkiol1z-v7dremusaaplj0rf_to261.jpg"/>


Related noun Explanation:

1) First line:

17:10:58: Indicates the current time of the system

Up 3:10: Indicates system run time, no restart during

3 Users: Indicates the number of people logged on to the system

Load average:0.00, 0.01, 0.05: Represents the average load of the past 1min, 5mins, 15mins. Load Average The data is the number of active processes that are checked every 5 seconds, and then the values calculated by the specific algorithm. If this number is divided by the number of logical CPUs, the result above 5 indicates that the system is overloaded.


2) The second line:

tasks:364 Total: Indicates how many processes are currently in the system

1 Running: indicates how many running processes are in the current system

363 Sleeping: A process that represents how many sleep states are in the current system

0 stopped: indicates how many stopped processes are in the current system

0 Zombie: indicates how many zombie processes are in the current system


3) The third line:

US: User space% CPU

SY: System (Kernel) space% CPU

NI: Percentage of processes in user space that have been changed by the NI value over the priority level

ID: Percentage of idle CPU

WA: Percentage of CPU waiting for IO to occupy

Hi: Percentage of CPU consumed by hard interrupts

Si: Percentage of CPU that is consumed by soft interrupts

ST: Percentage of CPU consumed by virtualization stolen


4) Line Fourth:

KiB Mem: Physical memory size in kilobytes

1003184 Total: Overall physical memory size

636564 Free: Idle physical memory size

156656 used: The amount of physical memory already in use

209964 Buff/cache: physical memory size for buffering and caching


5) Line Fifth:

KiB Swap: represents the virtual memory size in kilobytes

2097148 Total: Overall virtual memory size

2097148 Free: Idle virtual memory size

0 used: virtual memory size already used

659500 Avail Mem: The amount of memory that can be used


6) Line Seventh:

PID: ID number of the process

User: Users calling the process

PR: Priority of the process

NI: The nice value of the process

VIRT: The amount of virtual memory used by the process, virt=swap+res

RES: The resident memory size of the process, Res=code+data

SHR: The shared memory size of the process

S: The state of the process. R:running;s:interruptable sleeping;d:uninterruptable sleeping;t:stopped;Z:zombie; State after general also with parameters:+: Foreground process ; L: multithreaded process; N: Low priority process; <: high priority process; S:session leader

%cpu: Percentage of CPU usage consumed by process

%MEM: Percentage of physical memory consumed by the process

Time+: The time the process uses the CPU

COMMAND: Name of the process


Interactive Operation Tips

Sort:

P: Sorted by percentage of CPU occupied

M: Sort by occupy memory percentage

T: Sort by cumulative CPU time


The first message shows:

Uptime information: l command

Task and CPU information: T command

Memory Information: M command


Internal Sub-command:

Exit Command: Q

Modify Refresh time interval: s

Terminates the specified process: K



Two: Htop command

The Htop command can be viewed as an upgraded version of the top command, which supports mouse manipulation, a more aesthetically pleasing interface, and more powerful features. It is used in the following format:

Htop [D|u|s]

Options:

-D #: Specify the delay interval;

-U USERNAME: Displays only the processes of the specified user

-S Colume: Sorting in the specified field

~]# Htop

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/78/80/wKioL1Z-YIWQLVeZAAELvN9O5o4396.png "title=" 4.png " alt= "Wkiol1z-yiwqlvezaaelvn9o5o4396.png"/>


The noun of the htop command is the same as the top, and the following is the internal subcommand:

L: Displays the list of files opened by the selected process

S: Track system calls for selected processes

T: Show the status of each process in a hierarchical relationship

A: Binds the selected process to a specified CPU core



Iii. Dstat Order

The Dstat command can be used to generate statistics for system resources in the following format:

Dstat [-AFV] [options:] [Delay (several seconds delayed) [count (a total of several times)]]

Common options:

-C,--CPU: Displaying CPU-related information

-c#,.. Total

-d,--disk: Displays information about the disk

-D SDA ...

-G: Show page-related rate data

-M: Display the relevant statistics of memory

Related statistics for-n:interface

-P: Show statistics related to process

-R: Displays statistics related to IO requests

-S: Displays statistics about swap

-TCP: Show TCP connection Status

-UDP: Show UDP connection Status

-raw: Show Raw socket status

-socket: Show Socket status

-IPC: Display IPC status

--TOP-CPU: Show CPU-intensive processes

--top-io: Show most io-intensive processes

--top-mem: Show the most memory-intensive processes

--top-lanterncy: The most deferred process

~]# Dstat 1 5

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/78/82/wKiom1Z-ZFfCO9RKAAA_JwYX3NU832.png "title=" 5.png " alt= "Wkiom1z-zffco9rkaaa_jwyx3nu832.png"/>



Four, PS command

The PS command can view process information in the system in the following format:

PS [Options]

Options according to different categories, it has 3 styles

UNIX options, which may is grouped and must is preceded by a dash (-).

BSD options, which may is grouped and must not being used with a dash ().

GNU long options, which is preceded by and dashes (--).


One of the most common combinations: aux

A: All terminal-related processes

x: All processes unrelated to the terminal

U: Display of process status information in user-centric organization

~]# PS aux


Two common combinations:-ef

-e: Show All Processes

-F: Show process information in full format

~]# Ps-ef


The three common combinations:-EFH

-F: Show process information in full format

-H: Displays information about the process in a hierarchical structure

Parameters:

P SR: Indicates on which CPU to run

C: Indicates CPU consumption percentage

~]# PS-EFH


Four common combinations:-eo,axo

O Field1,field2, ... : Customize the list of fields to display, separated by commas;

Common Field:pid,ni,priorty (priority), PSR,PCPU,STAT,COMM,TTY,PPID,RTPRI (real-time priority)

~]# Ps-eo Pid,ni,comm



V: summary

The above command is basically a common process view command, and there are no administrative commands.

Reference: www.magedu.com

http://letitbe1028.blog.51cto.com/7901525/1699260

Http://www.jb51.net/LINUXjishu/151995.html

This article is from the "give me a piece of two-foil" blog, please be sure to keep this source http://theneverland.blog.51cto.com/10714090/1728609

Brief analysis of Linux process management commands

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.