Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example of the use of the ps process view command in the Linux system

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "Linux system ps process view command use examples", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "Linux system ps process view command use examples" bar!

The ps command in linux is an abbreviation for Process Status. The ps command lists the processes currently running on the system, and the listed processes are running at the time the ps command is executed.

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

Through the ps command, you can determine which processes are running and running status, whether the process ends, whether the process is dead, which processes take up too much resources, and so on.

To kill a process, use the kill command, for example: kill 12345 (12345 is the pid of the process)

The linux process has five states

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

two。 Interrupt (dormancy, block, or wait for a condition to be formed or receive a signal)

3. Uninterruptible (unawakened and unrunnable upon receipt of the signal, the process must wait until an interruption occurs)

4. Deadlock (the process is terminated, but the process descriptor exists until the parent process calls the wait4 () system call to release)

5. Stop (the process stops running after being signaled by SIGSTOP,SIGSTP,SIGTIN,SIGTOU)

The identification codes for the five process states of ps are as follows:

R runs runnable (on run queue)

S interrupt sleeping

D non-interruptible uninterruptible sleep (usually IO)

Z zombie a defunct ("zombie") process

T stop traced or stopped

Command parameter

A show all processes

-a displays all programs under the same terminal

-A shows all processes

C display the real name of the process

-N reverse selection

-e equals "- A"

E display environment variables

F shows the relationship between programs

-H shows the tree structure

R displays the progress of the current terminal

T displays all the programs of the current terminal

U specify all processes of the user

-au displays more detailed information

-aux displays all processes that contain other users

-C lists the status of the specified command

-number of rows displayed per page of lines

-number of characters displayed per page of width

-help displays help information

-version display version display

The meaning of the output column

F represents the flag of the program (flag), and 4 represents the user as super user

S represents the status of the program (STAT), and 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.

Percentage of resources used by C CPU

PRI this is the abbreviation of Priority (priority execution order), which will be described in more detail.

NI this is the Nice value, which we will continue to introduce in the next section.

ADDR this is kernel function, indicating which part of the program is in memory. If it is a running program, it is usually "-"

The amount of memory used by SZ

WCHAN, is this program currently in operation? if yes, it indicates that it is in operation.

The terminal location of the TTY login

The CPU time used by TIME.

Instructions issued 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

4? 00:00:00 kworker/0:0

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

6? 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 some of the results

two。 Displays 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 some of the 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 00 22:53? 00:00:01 / sbin/init

Root 2 00 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 some of the results

4. Used in conjunction with the 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 some of the results

5. Displays the bash-related processes of the currently logged-in user

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 800-7011 wait pts/0 00:00:00 bash

0 R 1000 2561 1805 0 800-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 some of the results

In addition:

A: displays processes initiated by other users

X: view your own processes in the system

U: the user who started the process and the startup time

Thank you for your reading, the above is the content of "the use of the ps process view command in the Linux system". After the study of this article, I believe you have a deeper understanding of the use of the ps process view command in the Linux system, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report