Linux Programming 6 (View process PS and output style)

Source: Internet
Author: User
A. View Process Command PS

1.1 Default PS command
    

By default, the PS command only shows the processes that are running under the current console and belong to the current user, in which we only run the bash shell and the PS command itself. Shows the program's process ID (1538,1583), which runs on the TTY terminal and the CPU time that the process already has.

1.2 PS style and parameters
The GNU PS command used in Linux systems supports 3 different types of command-line arguments. Includes UNIX-style parameters, BSD-style parameters, and GNU-style long parameters.

two. Unix Style parameters

In PS each style parameters are many, the following examples of some common Unix-style PS command parameters. There are a number of parameters that are not listed in the table below.

Parameters

Describe

-A

Show All Processes

-N

Show all processes that do not match the specified parameters

-A

Show all processes except control and no terminal processes

-D

Show all processes except the control process

-E

Show All Processes

-C Cmdlist

Show the processes contained in the Cmdlist list

-F

Show output in full format

-L

Show long list

2.1 Ps–ef parameter Combination command

Most Linux system administrators have their own set of parameters to extract useful process information. For example, you can use the-EF parameter combination as shown:
    

In the above list, the output information includes the following: The UID column refers to the user who initiated these processes. The PID column refers to the process ID. The Ppid column refers to the parent process ID (the process is started by another process). Column C refers to the CPU utilization in the process life cycle. The stime column refers to the system time when the process starts. A TTY column is a terminal device at the start of a process. The time column refers to the cumulative CPU times required by the running process. The cmd column refers to the program name that is started.

2.2 Ps–l long list

If you want to get more information, you can take the-l parameter, which produces a long-form output, as shown in:
    

In the above list, the output information includes: The F column refers to the system token that the kernel assigns to the process. S refers to the process state (O is running. S is dormant. R is operational and is waiting to be run. Z is rigid, the process is finished but the parent process no longer exists, and T is stopped. The PRT column refers to the priority of the process (the higher the number table, the lower the priority). NT column refers to the value of humility, used to participate in the decision of priority. The addr column refers to the memory address of the process. The SZ column refers to the approximate size of the required swap space if the process is swapped out. The Wchan column refers to the address of the kernel function where the process sleeps.

2.3 Ps–ef|grep XX Lookup process

Command grep is find, middle | is a pipeline command that represents PS and grep executing simultaneously. grep is a powerful text search tool that can use regular search files and print out matching lines. The following is a process that matches the Nginx character, and the process information column name is also masked with grep filtering.

    

The following command adds an L-long list display.
    

The second column value is S, which indicates that the current nginx process is dormant and the third column UID belongs to the HSR user.

three. BSD Style parameters

BSD style parameters of the PS command parameters are commonly used as follows (many others are not listed)

Parameters

Describe

R

Show only running processes

T

Show all processes associated with the current terminal

A

Show all processes associated with any terminal

G

Show all processes, including control processes

L

Use long mode

When using BSD parameters, the PS command automatically changes the output to mimic the UNIX format. For example: Use the parameter L output:
    

The output in the column is the same as the Unix style output. Only a small part of the difference includes the vsz that refers to the size of the process in memory, in KB units. RSS refers to the physical memory that the process occupies when it is not swapped out. STAT: A two-character status code that represents the current process state.

In the stat two-character status code, the first character is the same as the UNIX S-column value. The latter character represents the following:

<: The process runs on a high priority level.

N: The process runs on a low priority level.

L: The process has a page lock in memory.

S: The process is the control process.

L: The process is multi-threaded.

+: The process runs in the foreground.

You can see that the Bash command is dormant. is a control process. PS is run at the front of the system.

four. GNU Style long parameter

The GNU long parameter style PS command parameters are commonly used as follows (many others are not listed)

--deselect

Show all processes, processes listed on the command line

--forest

Hierarchy shows the relationship between a process and a parent process

For example, use the combined parameter output. As shown in the following:
    
For example, combine parameter output with its UNIX style. As shown in the following:
    

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.

Tags Index: