PS process in Linux system view command use instance Highlights

Source: Internet
Author: User
Tags command line

The PS command in Linux is the abbreviation for process status. The PS command lists the processes that are currently running on the system, and the processes listed are those that are running at this point in time to perform the PS command.

If you want to dynamically display process information, you need to use the top command.

The PS command allows you to determine which processes are running and running, whether the process is over, whether the process is dead, which processes are consuming too many resources, and so on.

To kill the process, use the KILL command, for example: Kill 12345 (12345 is the PID of the process)

There are 5 states of the Linux process

1. Run (running or waiting in the run queue)

2. Interrupted (dormant, obstructed, or waiting for a condition to form or receive a signal)

3. Not interrupted (Received signal does not wake up and not run, the process must wait until the interruption occurs)

4. Zombie (process terminated, but process descriptor exists until the parent process calls the WAIT4 () system call to release)

5. Stop (the process is sigstop,sigstp,sigtin,sigtou after the signal stops running)

The identification code for the PS 5 process status is as follows:

R run runnable (on run queue)

S Interrupt Sleeping

D non-disruptive uninterruptible sleep (usually IO)

Z Zombie a defunct ("zombie") process

T stop traced or stopped

Command Arguments

A Show All Processes

-a displays all programs under the same terminal

-A shows all processes

C shows the real name of the process

-N Reverse Selection

-e equals "-A"

E Show Environment variables

F Display the relationship between programs

-H Display tree structure

R shows the process of the current terminal

T displays all programs for the current terminal

U specify all processes for the user

-au displays more detailed information

-aux shows all processes that contain other users

-c< command > List the status of the specified command

–lines< number of rows > number of rows displayed per page

–width< characters > number of characters displayed per page

–HELP Display Help information

–version Display version display

What the output column means

F represents the flag of this program (flag), 4 represents the user as Super user

S represents the state of the program (STAT), the meaning of each STAT will be introduced in the text

The UID program is owned by the UID

ID of the PID process

PPID is the ID of its parent program

Percent of resources used by the C CPU

PRI this is the abbreviation for Priority (priority execution), which is described later in detail

NI This is nice value, we will continue to introduce in the next section

ADDR This is the kernel function, which indicates the part of the program that is stored. If it's a running program, it's usually "-"

The amount of memory used by SZ

Wchan is the program currently in operation, if--indicating that it is operating

The terminal location of the TTY login

The CPU time to use.

The instructions given by CMD

Example:

1. Show all process information

The code is as follows:

fdipzone@ubuntu:~$ ps-a

PID TTY Time CMD

1? 00:00:01 Init

2? 00:00:00 Kthreadd

3? 00:00:00 ksoftirqd/0

6} 00:00:00 kworker/0:0

5? 00:00:00 kworker/u:0

4} 00:00:00 migration/0

7? 00:00:00 MIGRATION/1

8? 00:00:00 kworker/1:0

9? 00:00:00 KSOFTIRQD/1

10? 00:00:00 kworker/0:1

... Omit partial results

2. Display the specified user process

The code is as follows:

fdipzone@ubuntu:~$ Ps-u Fdipzone

PID TTY Time CMD

1502? 00:00:00 gnome-keyring-d

1521? 00:00:00 gnome-session

1551? 00:00:00 Ibus-daemon

1555? 00:00:00 ssh-agent

1558? 00:00:00 Dbus-launch

1559? 00:00:00 ibus-gconf

1561? 00:00:00 python

1563? 00:00:00 Dbus-daemon

1564? 00:00:00 ibus-x11

1569? 00:00:00 gconfd-2

... Omit partial results

3. Show all processes and display the command line

The code is as follows:

fdipzone@ubuntu:~$ Ps-ef

UID PID PPID C stime TTY time CMD

Root 1 0 0 22:53? 00:00:01/sbin/init

Root 2 0 0 22:53? 00:00:00 [Kthreadd]

Root 3 2 0 22:53? 00:00:00 [ksoftirqd/0]

Root 4 2 0 22:53? 00:00:00 [kworker/0:0]

Root 5 2 0 22:53? 00:00:00 [kworker/u:0]

Root 6 2 0 22:53? 00:00:00 [migration/0]

Root 7 2 0 22:53? 00:00:00 [MIGRATION/1]

Root 8 2 0 22:53? 00:00:00 [kworker/1:0]

Root 9 2 0 22:53? 00:00:00 [KSOFTIRQD/1]

Root 10 2 0 22:53? 00:00:00 [Kworker/0:1]

... Omit partial results

4. Use in combination with grep command to find the specified process

The code is as follows:

fdipzone@ubuntu:~$ Ps-ef | grep Apache

Root 2032 1 0 22:56? 00:00:01/usr/sbin/apache2-k start

Www-data 2318 2032 0 22:58? 00:00:00/usr/sbin/apache2-k start

Www-data 2319 2032 0 22:58? 00:00:00/usr/sbin/apache2-k start

Www-data 2320 2032 0 22:58? 00:00:00/usr/sbin/apache2-k start

Www-data 2321 2032 0 22:58? 00:00:00/usr/sbin/apache2-k start

Www-data 2322 2032 0 22:58? 00:00:00/usr/sbin/apache2-k start

Www-data 2323 2032 0 22:58? 00:00:00/usr/sbin/apache2-k start

... Omit partial results

5. Display the currently logged in user's bash-related process

The code is as follows:

fdipzone@ubuntu:~$ ps-l

F S UID PID PPID C PRI NI ADDR SZ Wchan TTY time CMD

0 S 1000 1805 1798 0 0-7011 wait pts/0 00:00:00 bash

0 R 1000 2561 1805 0 0-3377-pts/0 00:00:00 PS

6. List all user-initiated processes

The code is as follows:

[fdipzone@ubuntu:~$ PS aux

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

Root 1 0.1 0.2 24136 2188? Ss 22:53 0:01/sbin/init

Root 2 0.0 0.0 0 0? S 22:53 0:00 [Kthreadd]

Root 3 0.0 0.0 0 0? S 22:53 0:00 [ksoftirqd/0]

Root 5 0.0 0.0 0 0? S 22:53 0:00 [kworker/u:0]

Root 6 0.0 0.0 0 0? S 22:53 0:00 [migration/0]

Root 7 0.0 0.0 0 0? S 22:53 0:00 [MIGRATION/1]

Root 8 0.0 0.0 0 0? S 22:53 0:00 [kworker/1:0]

Root 9 0.0 0.0 0 0? S 22:53 0:00 [KSOFTIRQD/1]

Root 10 0.0 0.0 0 0? S 22:53 0:00 [kworker/0:1]

Root 11 0.0 0.0 0 0? s< 22:53 0:00 [Cpuset]

Root 12 0.0 0.0 0 0? s< 22:53 0:00 [Khelper]

... Omit partial results

Other than that:

A: Show processes initiated by other users

x: View the processes that are part of your system

U: Start the user and start time for this process

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.