Linux commonly used commands ps (process status)

For record, refer to the following two blogs:

https://blog.csdn.net/freeking101/article/details/53444530

https://blog.csdn.net/u011441473/article/details/80555694

The ps command in Linux is short for Process Status. The ps command is used to list the processes currently running in the system. The ps command lists the snapshots of the current processes, that is, the processes at the moment when the ps command is executed. To display process information dynamically, use the top command.

This command can determine which processes are running and running status, whether the process is over, whether the process is dead, which processes are occupying too many resources, and so on.

ps provides a one-time view of the process, and the view results provided are not dynamic and continuous. If you want to monitor the process time, you should use the top tool.

The kill command is used to kill the program

There are 5 states of processes on linux: 

  1. Run (R, runnable (on run queue))-running or waiting in the run queue
  2. Interrupt (S, sleeping) —— during sleep, blocked, waiting for the formation of a certain condition or receiving a signal
  3. Uninterruptible (D, uninterruptible sleep (usually IO))-receiving a signal does not wake up and cannot run, the process must wait until an interrupt occurs
  4. Zombie (Z, a defunct ("zombie") process)-the process has been terminated, but the process descriptor exists until the parent process calls the wait4() system call and releases it
  5. Stop (T, traced or stopped)-the process stops running after receiving SIGSTOP, SIGSTP, SIGTIN, SIGTOU signals

Common parameters:

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

-a Display all processes of a terminal, except for the session lead -N ignore selection.

-d displays all processes, but omits all session leads (utility)

-x displays the process without controlling the terminal, and displays the specific path of each command. dx cannot be used together. (Utility)

-p pid The time the process uses the cpu

-u uid or username select a valid user id or username

-g gid or groupname displays all processes in the group.

U username displays all processes under this user, and displays the detailed path of each command. Such as: ps U zhang; (utility) -f lists all, usually combined with other options. Such as: ps -fa or ps -fx and so on.

-l long format (with F, wchan, C and other fields)

-j job format

-o User-defined format.

v Display in virtual storage format

s Display in signal format

-m show all threads

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

Display the environment after the e command (eg: ps -de; ps -ae) (utility)

h does not display the first line

Use case:

  ps -auxf | grep **

  Display all process information

        ps -A

    Display the information of the specified user

        ps -u root

    Display all process information, together with the command line

        ps -ef

    Commonly used combination of ps and grep to find specific processes

        ps -ef | grep ssh

    List the PID and related information currently belonging to your own login this time

Guess you like

Origin blog.csdn.net/Answer3664/article/details/105765493