"Linux Command" ps-aux detailed explanation

Source: Internet
Author: User

This article is reproduced from http://blog.chinaunix.net/uid-21516619-id-1824945.html

Show other user-initiated processes (a) View the processes that are part of your system (x) the user who started the process and the time it Started (U)   Use the "date-s" command to modify the system time such as the command to set the system time to June 10, 1996 as follows. #date-S 06/10/96 the command to set the system time to 1:12 P.M. 0 seconds is as follows. #date-S 13:12:00 ------------------------------------------------------USER PID%cpu%MEM VSZ RSS TTY STAT START TI ME commandroot 1 0.0 0.0 1340 440? S Nov05 0:04 initroot 2 0.0 0.0 0 0? SW Nov05 0:00 [keventd]root 3 0.0 0.0 0 0? SW Nov05 0:00 [keventd] ...------------------------------------------------------the  user field indicates which user initiated the command; Users can see how much CPU is consumed by a process, memory usage and its vsz (virtual memory size) and RSS (resident set size): Vsz indicates how much memory space is required if a program resides completely in memory; RSS indicates how much memory is currently in use; Stat shows the current state of the process: "S": The process is asleep, indicating that these processes are waiting for certain events to occur--either user input or availability of system resources; The  last command can effectively view system logon events   after a process has called exit, Instead of disappearing immediately, the process leaves behind a data structure called the zombie process (Zombie). In the 5 states of the Linux process, the zombie process is a very special one, it has abandoned almost all memory space, no executable code, and can not be scheduled, just keep a position in the process list, record the process's exit status and other information for other processes to collect, in addition, The zombie process no longer occupies any memory space.   System call exit is for the process to exit, but it is limited to turning a normal process into a zombie process and cannot completely destroy it. Once the process has called wait, it immediately blocks itself, and the wait automatically parses if a child process of the current process has exited, and if it finds such a child process that has become a zombie, wait collects the child process information and destroys it and returns it.If no such sub-process is found, wait is stuck here until one appears.   Reprint  ps aux in stat explanation collection   run PS aux to the following information:   PS auxuser    pid  %CPU%MEM VSZ &nbs P RSS TTY    stat   START time Commandsmmsp 3521   0.0    0.7     6556 1616   & nbsp;?       &NBSP;SS      20:40 0:00 sendmail:queue [email protected]:00:00 froot   &NB sp;3532    0.0       0.2     2428    452    ?       &NBSP;SS      20:40 0:00 gpm-m/dev/input/mice-t imps2htt       &NBSP ; 3563    0.0       0.0    2956    196    ?       &NBSP;SS       20:41 0:00/usr/sbin/htt-retryonerror 0htt         3564    0.0       1.7   29460 3704    ?       &NBSP;SL       &NBSP;20: 0:00 htt_server-nodaemonroot      3574    0.0       0.4     5236 99 2    ?       &NBSP;SS       20:41 0:00 crondxfs        3617    0.0 &N Bsp     1.3   13572 2804    ?       &NBSP;SS       20:41 0:00 xfs-droppriv-daemonroot       3627   0 .0       0.2     3448    552    ?        sns     20:41 0:00 anacron-sroot      3636    0.0   &N Bsp   0.1     2304    420    ?       &NBSP;SS       20:41 0:00/usr/sbin/atddbus    3655    0.0       0.5   13840 1084    ?       &NBSP;SSL       20:41 0:00 dbus-daemon-1--system ..................The parameters in stat are as follows:   D non-interruptible uninterruptible (usually IO)    R is running, or the process in the queue    S is dormant & nbsp;  T stop or be traced    Z zombie process    W into memory swap (invalid starting from kernel 2.6)    X   dead process     & nbsp;< High priority     n   Low priority     s   include child processes     +   process groups in the background  ====================================== ps command to monitor and control the process, you must first understand the current process, that is, you need to view the current process, The PS command is the most basic and very powerful process view command. Use this command to determine which processes are running and running, whether the process is complete, if the process has no zombies, Which processes consume too much resources, and so on. In short, most of the information can be obtained by executing the command. The most common use of the PS command is to monitor the work of the background process, because the background process is not communicating with these standard input/output devices on the on-screen keyboard, so if you need to detect its condition, You can use the PS command .         1) PS A shows all the programs under the current terminal, including other users ' programs. 2) ps-a Show All Programs. 3) PS C lists the program, displays the actual instruction name of each program, and does not include the path, parameter or the indication of the resident service. 4) Ps-e The effect of this parameter is the same as specifying the "A" parameter. 5) When listing the program, PS e displays the environment variables used by each program. 6) PS F Displays the tree structure with ASCII characters, expressing the relationship between the programs. 7) ps-h shows the tree structure, indicating the relationship between the programs. 8) Ps-n shows all the programs except the program under the PS Command Terminal. 9) PS s uses the program signal format to display the program status. PS S when listing programs, including interrupted sub-program data. ps-t< Terminal number > Specify the terminal number, and list the status of the program belonging to the terminal.  PS uDisplays the status of the program in a user-oriented format. PS x Displays all programs and does not differentiate by terminal. The most common approach is to Ps-aux, and then use a pipe symbol to direct to grep to find a specific process and then manipulate the specific process. The    linux process has 5 states: 1. Run (running or waiting in the running queue) 2. Interrupts (dormant, blocked, waiting for a condition to form or receive to signal) 3. Non-interruptible (the received signal does not wake up and is not operational, the process must wait until there is an outage) 4. Zombie (The process has been terminated, but the process descriptor exists until the parent process calls WAIT4 () after the system call is released) 5. Stop (process receives sigstop, SIGSTP, Sigtin, Sigtou signal after stop running) &NBSP;PS tool identifies 5 status codes for the process: D Non-interruptible uninterruptible sleep (usually IO) R run runnable (on Run queue) S interrupt Sleepingt stop traced or Stoppedz zombie a defunct ("Zom Bie ") process  Note: Other states also include W (no Dwell page), < (high priority process), N (Low priority process), L (Memory lock page) .  use PS format output to view process status: Ps-eo user,stat..,cmd  user User name UID user number PID process number PPID parent process number size, Kbytes bytes. vsize Total virtual memory size, Bytes bytes (including code+data+stack) share total number of shared pages Nice process priority ( Default is 0, Max -20) priority (PRI) kernel scheduling priorities PMEM process share percent of physical memory the TRS program executes code resident size the total amount of physical memory used by the RSS process, Kbytes bytes time Process execution is now the total CPU take up time stat process state cmd (args) Simple format   Example: View the Uid,pid,stat,pri of the current system process, sorted by UID number. Ps-eo pid,stat,pri,uid– Sort uid  View the User,pid,stat,rss,args of the current system process, sorted by RSS. Ps-eo User,pid,stat,rss,args–sort RSS&NBsp;   Name: PS Use Rights: All users use: PS [options] [--help] Description: Show the dynamic parameters of the instantaneous trip (process): PS parameters are very many, here only a few common parameters and a brief description of the meaning-a List all trips W-display widen to show more information-au show more detailed information-aux Show all itineraries containing other users  au (x) output format:  user PID%cpu%MEM VSZ RSS TTY STAT START TI ME Commanduser: Trip owner pid:pid%cpu: CPU usage%mem: Memory usage vsz: occupied virtual memory size RSS: Occupied memory size TTY: Secondary device number of the terminal (minor device numb Er of TTY) STAT: The status of the trip: D: Non-interruptible static R: Executing in S: Stationary State t: Pause execution Z: not present but temporarily unable to eliminate W: there is not enough memory paging to allocate <: High priority stroke N: Low priority stroke L: Memory paged out and locked in record Recalling the body start: Start time: Time of execution command: executed instruction   Example:  pspid TTY CMD2791 ttyp0 00:00:00 tcsh3092 ttyp0 00:00:00 ps% Ps-apid TTY time CMD1? 00:00:03 init2? 00:00:00 kflushd3? 00:00:00 kpiod4? 00:00:00 kswapd5? 00:00:00 mdrecoveryd.......% ps-auxuser PID%cpu%MEM VSZ RSS TTY STAT START time commandroot 1 0.0 0.7 1096 472? S Sep10 0:03 init [3]root 2 0.0 0.0 0 0? SW SEP10 0:00 [kflushd]root 3 0.0 0.0 0 0? SW SEP10 0:00 [kpiod]root 4 0.0 0.0 0 0? SW SEP10 0:00 [kswapd]........   to monitor and control the process,The first thing you have to know about the current process is that you need to see the current process, and the PS command is the most basic and very powerful process view command. Use this command to determine which processes are running and running, whether the process is complete, if the process is zombie, which processes are consuming too many resources, and so on. In short, most of the information can be obtained by executing the command.  ps provides us with a one-time view of the process, which provides a view of the results that are not dynamic, and that you should use the top tool if you want to monitor process times.  kill is used to kill processes. &NBSP;1, PS parameter Description PS provides a lot of options parameters, commonly used in the following:  l long format output; U displays the process in the order of the user name and start time; J Displays the process in the task format; F Displays the process in a tree format;  a Displays all processes for all users (including other users), X shows processes with no control terminal, R shows running processes; WW avoids detailed parameters being truncated;  Our common options are the combination of aux or lax, and the application of parameter F. The  2, PS aux or lax output explains the owner of the user process, the id;ppid parent process of the PID process, the percentage of CPU used by the%CPU process, the percentage of memory occupied by the%MEM, the nice value of the NI process, the large number, which indicates less CPU time, and the VSZ process The virtual size, the number of pages that RSS resides in, the TTY terminal Idstat process state (there are several)  d the dormant state (usually IO), which can be run in the queue, and S is dormant; T stopped or was traced; Enter memory swap (invalid from kernel 2.6); X dead process (never seen); Z Zombie Process; < Priority high process n lower priority process L some pages are locked into memory; the leader of the S process (under which there are sub-processes); L multi-process (using Clone_ THREAD, similar to NPTL pthreads); + The process group in the background, the process resource that Wchan is waiting for, the time the START process starts, the time the process consumes the CPU, the name and parameters of the command, &NBSP;3, application example [[ Email protected] ~]# Ps-aux |more can be used | The pipe and more are linked up for pagination viewing. [[email protected] ~]# ps-aux > ps001.txt[[email Protected] ~]# More ps001.txt Here is the display of all the processes, and output to the Ps001.txt file, and then through more to Page view. &NBSP;4, kill termination process has more than 10 ways to control the process, here are some common methods: kill-stop [PID] Send Sigstop (17,19,23) to stop a process, and not eliminate the process. Kill-cont [PID] sends Sigcont (19,18,25) to restart a stopped process. Kill-kill [PID] Send Sigkill (9) forces the process to stop immediately and does not implement a cleanup operation. Kill-9-1 Stop all the processes you have. SIGKILL and SIGSTOP signals cannot be captured, blocked, or ignored, but other signals can. So this is your ultimate weapon.

Linux Command ps-aux detailed explanation

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.