Brief description of Linux PS commands and output style parameters

View process PS

Default PS

By default, the PS command only displays running under the current console, belonging to the current user, in the above image, we only run BASH and the PS command itself. The process ID (1538, 1583) of the program is shown in the above figure, which is running on the TTY terminal, and the CPU (Time) time that the process existing.

PS style and parameters

The GNU PS command used in the medium supports three different types of command line parameters. Including parameters, BSD style parameters, long parameters of the GNU style.

UNIX style parameters

There are many parameters for each style in the PS, and the following examples will give some commonly used UNIX style PS command parameters. There are still many parameters that are not listed below.

PS-EF parameter combination command

Most system administrators have their own set of parameters to extract useful process information. For example, the -ef parameter is used, as shown below:

In the above list, the information output includes: the UID column refers to a user that starts these processes. The PID column is the process ID. PPID column means: The parent process ID (this process is started by another process). The C column refers to the CUP utilization in the process lifecycle. The STIME column is the system time when the process is started. The TTY column refers to the terminal device at which the process is started. The Time column refers to the cumulative CPU time required to run the process. The CMD column is the program name that is started.

PS -L long list

If you want to get more information, you can use the -l parameter, which generates a long format, as shown below:

In the above list, the output information includes: F column refers to a system tag assigned to the process. S is the state of the process (o is running. S is sleep. R is running, waiting for run .z is rigid, the process has ended, but the parent process has no existence, T is stopped). The PRT column refers to the priority of the process (the lower the priority of the number of numbers). The NT column refers to the modification value and is used to participate in the decision priority. The AddR column refers to the memory address of the process. The SZ column means that if the process is replaced, the required switching space is substantially large. The WCHAN column refers to the address of the kernel function sleeping.

PS-EF | GREP XX Find Process

The command grep is looking for, the middle | is the pipeline command, which is executed simultaneously with GREP. GREP is a powerful text search tool that uses the regular search file and prints the matching line. Below is a process related to nginx characters, and the process information column name is also blocked with GREP filtering.

The following command adds the L-list display.

The second column of the above figure is S, which represents the current nginx process is a sleep state, and the third column UID is an HSR user.

BSD style parameters

The PS command parameters of the BSD style parameters are commonly used as follows (there are many other unlisted)

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

The column output in the figure is the same as the Unix style output. Only small partially different includes VSZ refers to the size of the process in memory, with a KB unit. RSS refers to the physical memory occupied by the process during the failure to change. Stat: Represents the two-character status code that represents the current process status.

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

It can be seen that the bash command is sleeping. It is a control process. PS is a front desk running in the system.

GNU style long parameters

The GNU long parameter-style PS command parameters are commonly used (many other are not listed)

For example, a combined parameter is used. As shown below:

For example, with its UNIX style combination parameter output. As shown below:

Originally from: