Linux PS Command Detailed

Source: Internet
Author: User
Tags session id time and date

Name: PS

Usage rights: All users

How to use: PS [options] [--help]

Description: Shows the dynamics of the instantaneous stroke (process)

Parameters: The parameters of PS are very many, only a few common parameters are listed here and the meaning

-A lists all processes

-W display widen to show more information

-au Show more detailed information

-aux Show all itineraries that contain other users

############################################################

Common parameters:

-A show all processes (equivalent to-e) (utility)

-a displays all processes of a terminal, in addition to session leader

-N ignores selection.

-D displays all processes, but omits all session leaders (utility)

-X displays a process that does not control the terminal, and displays the specific path of each command. DX cannot be combined. (utility)

-p PID process uses CPU time

-U uid or username Select a valid user ID or user name

-G gid or groupname displays all processes for the group.

U username Displays all processes under the user, and displays the detailed path of each command. such as: PS U Zhang; (utility)

-F is all listed, and is usually used with other options. such as: Ps-fa or Ps-fx and so on.

-L long format (with fields such as F,wchan,c)

-J Job Format

-o user-defined format.

V display in virtual memory format

s displayed in signal format

-M Show All threads

-H displays the level of the process (shared with other commands, such as: ps-ha) (utility)

The e command then displays the environment (for example: ps-d e; Ps-a e) (utility)

H does not display the first line

############################################################

ps Command common usage (easy to view system process)

1) PS A shows all the programs under the current terminal, including other users ' programs.

2) ps-a Show all processes.

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 U Displays 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.

############################################################

Run PS aux to the following information:

root:# PS aux

USER PID%cpu%MEM VSZ RSS TTY STAT START time COMMAND

Smmsp 3521 0.0 0.7 6556 1616? Ss 20:40 0:00 sendmail:queue [email protected]:00:00 f

Root 3532 0.0 0.2 2428 452? Ss 20:40 0:00 gpm-m/dev/input/mice-t imps2

HTT 3563 0.0 0.0 2956 196? Ss 20:41 0:00/usr/sbin/htt-retryonerror 0

HTT 3564 0.0 1.7 29460 3704? Sl 20:41 0:00 Htt_server-nodaemon

Root 3574 0.0 0.4 5236 992? Ss 20:41 0:00 Crond

XFS 3617 0.0 1.3 13572 2804? Ss 20:41 0:00 Xfs-droppriv-daemon

Root 3627 0.0 0.2 3448 552? SNs 20:41 0:00 anacron-s

Root 3636 0.0 0.1 2304 420? Ss 20:41 0:00/USR/SBIN/ATD

Dbus 3655 0.0 0.5 13840 1084? SSL 20:41 0:00 dbus-daemon-1--system

Head Header:

User username

UID Subscriber ID (user ID)

PID Progress ID (Process ID)

PPID Process ID (parent process ID)

SID Conversation ID (session ID)

CPU utilization of the%CPU process

Memory utilization of the%MEM process

The size of the virtual memory used by the VSZ process (virtual size)

The size of the resident set used by the RSS process, or the size of the actual memory, Kbytes bytes.

TTY associated with a process terminal (TTY)

Status of the stat process: process State is represented by a character (stat's status code)

R runs Runnable (on Run queue) is running or waiting in the run queue.

S sleep sleeping dormant, obstructed, waiting for a condition to form or receive signals.

I Free Idle

The Z Zombie Zombie (a defunct process) session has been terminated, but the process descriptor exists until the parent process calls the WAIT4 () system call and releases.

D non-interruptible uninterruptible sleep (ususally IO) receives a signal that does not wake up and is not operational, and the process must wait until an interrupt occurs.

T terminates the Terminate process to receive sigstop, SIGSTP, Sigtin, and Sigtou signals after it stops running.

P Wait for Exchange page

W no-resident page has no resident pages there is not enough memory paging to allocate.

X dead Process

< high-priority process

N low-priority process with lower priority sequence

L Memory Lock page lock has memory paging allocated and shrunk in memory body

Leader of the S-process (under it there are sub-processes);

L multi-process (using Clone_thread, similar to NPTL pthreads)

+ process groups in the background

Start process startup time and date

The total CPU time used by the duration process

command-line command being executed

NI Priority (Nice)

PRI Process Precedence Number (priority)

The name of the kernel function in which the Wchan process is sleeping; the name of the function is obtained from the/root/system.map file.

FLAGS and process-related digital IDs

############################################################

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

############################################################

PS gives us a one-time view of the process, it provides a view of the results is not dynamic continuous, if you want to monitor the process, you should use the top tool.

1, PS parameter description:

PS offers a number of options parameters, commonly used in the following several:

l long format output;

U displays the process in the order of the user name and start time;

J Use the task format to display the process;

F to display the process in a tree-shaped format;

A shows all processes of all users (including other users);

X shows the process without control terminal;

R shows the running process;

WW avoids detailed parameters being truncated;

Our common options are the combination of aux or lax, and the application of parameter F.

2. Explanation of PS aux or lax output:

Owner of the USER process;

The ID of the PID process;

PPID parent process;

Percentage of CPU consumed by the%CPU process;

%MEM% of memory occupied;

The nice value of the NI process, which is large, means that it consumes less CPU time;

VSZ process virtual size;

The number of pages that RSS resides in;

TTY Terminal ID

STAT process status (with the following types)

D a dormant state (usually IO process) that cannot be interrupted;

R is running can be in the queue can be too line;

S is in a dormant state;

T stop or be traced;

W enters memory swap (invalid starting from kernel 2.6);

X dead process (never seen);

Z Zombie process;

< high-priority processes

N Low-priority processes

L Some pages are locked into memory;

Leader of the S-process (under it there are sub-processes);

L multi-process (using Clone_thread, similar to NPTL pthreads);

+ Process Group located in the background;

Wchan the process resources being awaited;

Start START process time;

The time the process consumes the CPU;

The name and parameters of the command commands;

3, Application Examples:

[Email protected] ~]# Ps-aux |more

Can be used | The pipe and more are linked up for pagination viewing.

[Email protected] ~]# Ps-aux > Ps001.txt

Output the results to the Ps001.txt text and save them.

[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.

4, kill kills the process, there are more than 10 ways to control the process, the following are some common methods:

[[Email protected] ~] #kill-stop [PID]

Send Sigstop (17,19,23) to stop a process without destroying it.

[[Email protected] ~] #kill-cont [PID]

Send Sigcont (19,18,25) to restart a stopped process.

[[Email protected] ~] #kill-kill [PID]

Send Sigkill (9) forces the process to stop immediately and does not implement a cleanup operation.

[[Email protected] ~] #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 PS Command Detailed

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.