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

Use the ps command of linux to display the process status

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will explain in detail about the use of linux's ps command to display the status of the process. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

The ps command is an abbreviation for "process status", and the ps command is used to display the process status of the current system. You can interrupt and delete unnecessary programs at any time with kill instructions.

Ps command is the most basic but also very powerful process view command, which can be used to 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. In short, most of the information can be obtained by executing the command.

Syntax format: ps [parameters]

Commonly used parameters: coach

-a displays all programs executed under the terminal, except for the phase job leader, a displays all programs under the current terminal, including programs of other users-A displays all programs-c displays CLS and PRI fields c lists programs, displays the real instruction name of each program, excluding the path, option or resident service indication-C specifies the name of the execution instruction And list the status of the program of the instruction-d shows all programs, but does not include the program of the phase job leader-e the effect of this option is the same as specifying the "A" option e when listing the program, display the environment variable used by each program-f display UID,PPIP,C and STIME field f display the tree structure with ASCII characters to express the interrelationship between programs-g this option has the same effect as specifying the "- G" option When you can also use the name of the phase operation leader to specify g to display all programs under the current terminal, including the group leader's program-G to list the status of the programs belonging to the group, you can also use the group name to specify that h does not display the title column-H displays the tree structure Indicates the interrelationship between programs-j or j displays the program status in a work-controlled format-l or l uses a detailed format to display program status L listed fields-m or m displays all threads n to represent USER and WCHAN fields-N displays all programs, except for programs under the ps instruction terminal-p specifies the program identification code And list the status of the program p the effect of this option is the same as that of specifying the "- p" option, except for a slight difference in the list format r only lists the program identification number of the current terminal in the specified phase of the operation, and lists the status of the program belonging to the operation at this stage s displays the program status S in the format of the program signal when listing the program, including the interrupted subroutine data-t specifies the terminal number And list the status of the programs belonging to the terminal t the effect of this option is the same as specifying the "- t" option, there is only a slight difference in the list format-T shows all programs under the current terminal-u the effect of this option is the same as specifying the "- U" option u shows the program status in a user-based format-U lists the status of the programs belonging to the user You can also use the user name to specify that U lists the status of the programs belonging to the user v displays the program status in the format of virtual memory-V or V displays version information-w or w uses a broad format to display the program status x displays all programs, not by the terminal X displays the program status in the old Linux i386 login format-y with the option "- l", the F (flag) field is not displayed And replace the ADDR field with the RSS field-- this option has the same effect as specifying the "p" option-- cols sets the maximum number of characters per column-- columns this option has the same effect as specifying the "--cols" option-- cumulative has the same effect as specifying the "S" option-- deselect this option has the same effect as specifying the "- N" option-- forest this option has the same effect as specifying the "f" option. Same as-- headers repeated display title column-- help online help-- info display troubleshooting information-- lines sets the number of columns on the display screen-- no-headers this option has the same effect as specifying the "h" option. Only slightly different in list format-group this option has the same effect as the specified "- G" option-- Group this option has the same effect as the specified "- G" option-- pid this option has the same effect as the specified "- p" option-- rows this option has the same effect as the specified "--lines" option-- sid this option has the same effect as the specified "- s" option-tty Result is the same as specifying "- t" option-- user this option has the same effect as specifying "- U" option-- User this option has the same effect as specifying "- U" option-- version this option has the same effect as specifying "- V" option-- widty this option has the same effect as specifying "- cols" option.

Reference example

Show all the processes:

[root@linuxcool ~] # ps-aux

[root@linuxcool] # ps-A

Show all the processes and output them to the ps.txt file:

[root@linuxcool ~] # ps-aux > ps.txt

Find specific process information:

[root@linuxcool ~] # ps-ef | grep ssh

Root 1303 1 0 Apr17? 00:00:00 / usr/sbin/sshd

Root 3260 3087 0 Apr17? 00:00:00 / usr/bin/ssh-agent / bin/sh-c exec-l / bin/bash-c "env GNOME_SHELL_SESSION_MODE=classic gnome-session-- session gnome-classic"

Root 24174 19508 0 11:39 pts/0 00:00:00 grep-color=auto ssh

[root@linuxcool ~] # ps-aux | grep ssh

Root 1303 0.0 0.0 82468 1204? Ss Apr17 0:00 / usr/sbin/sshd

Root 3260 0.0 0.0 52864 572? Ss Apr17 0:00 / usr/bin/ssh-agent / bin/sh-c exec-l / bin/bash-c "env GNOME_SHELL_SESSION_MODE=classic gnome-session-- session gnome-classic"

Root 24188 0.0 112652 956 pts/0 S+ 11:39 0:00 grep-- color=auto ssh

Displays the specified user information:

[root@linuxcool] # ps-u root

[root@linuxcool ~] # ps aux | sort-nk 3

Sort processes by memory resource usage:

[root@linuxcool ~] # ps aux | sort-rnk 4

On the use of linux ps command to show the status of the process is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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