Linux PS command

Source: Internet
Author: User

Syntax Note:

The PS (process status) command comes in 2 different styles, namely BSD and UNIX. New users often confuse and interpret both styles in a wrong way. So to figure them out, before proceeding, here are some basic information.

Note: "PS aux" and "ps-aux" are not the same. Examples such as "-U" are used to display the user's process. But "U" is the display of detailed information.

BSD style: The BSD-style syntax option is not with hyphens before.

    1. PS aux

Unix/linux style: There is a dash in front of the Linux style syntax options as usual. ...

    1. Ps-ef

Mixing the syntax styles on two Linux systems is a good thing. such as "PS Ax-f". But in this article, we will focus primarily on UNIX-style syntax.

How do I use the PS command?

1. Show All Processes:

The following command lists all the processes:

    1. $ ps AX
    2. $ ps-ef

Add pipe output to less to scroll the display

"U" or "-F" parameter to display details of all processes

    1. $ ps aux
    2. $ ps-ef-f

Note: Why the user column does not display my user name, but shows other users, such as root, www, etc., for all usernames (including you) if the length is greater than 8 characters, then PS will only display the UID, not the user name.

3. Display the process by name and process ID:

Search for a process by name or command, using the "-C" option followed by a search term.

    1. $ ps-c Apache2
    2. PID TTY Time CMD
    3. 2359? 00:00:00 apache2
    4. 4524? 00:00:00 apache2
    5. 4525? 00:00:00 apache2

------------------------

To monitor and control the process, you must first understand the current process, that is, 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 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 .

The KILL command is used to kill the process.

There are 5 states of processes on Linux:

1. Running (running or waiting in the running queue)

2. Interrupt (dormant, blocked, waiting for a condition to form or receive a signal)

3. Non-interruptible (receive signal does not wake up and not run, process must wait until interrupt occurs)

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 received Sigstop, SIGSTP, Sigtin, Sigtou signal after stop running run)

PS Tool identifies 5 status codes for the process:

D non-interruptible uninterruptible sleep (usually IO)

R run runnable (on run queue)

S Interrupt Sleeping

T stop traced or stopped

Z Zombie a defunct ("zombie") process

PS and grep common use combination to find specific processes

Command:

Ps-ef|grep SSH

Linux PS command

Related Article

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.