Tutorial of using PS command and gitps command in Linux system

Time:2020-4-5

ps

PS [- aacdefhjlmnvwy] [acefghlnrsstuvxx] [- C < instruction name >] [- G < group name >]

[- G < group ID >] [- P < process ID >] [- s < phase job >]

[- T < terminal number >] [T < terminal number >] [- U < user ID code >] [- U < user ID code >]

[U < user name >] [- < process ID >] [– cols < characters per column >]

[– columns < characters per column >] [– cumulative] [– deselect] [– forest]

[– headers] [– help] [– info] [– lines < display columns >] [– no headers]

[– group < group name >] [- group < group ID >] [– PID < process ID >]

[– rows < number of display columns >] [– Sid < phase job >] [– TTY < terminal number >]

[– user < user name >] [– user < user ID >] [– version]

[– width < characters per column >]

Parameter Description:

– a shows the progress executed under all terminals except the phase operation leader.
A. display all processes under the current terminal, including those of other users.
– a shows all processes.
– C displays the CLS and PRI fields.
C. when the process is listed, the actual instruction name of each process will be displayed, without path, parameter or resident service identification.
– C < instruction name > specifies the name of the execution instruction and lists the status of the process that executed the instruction.
– D shows all processes, but does not include the process of the phase job leader.
– e this parameter has the same effect as specifying the “a” parameter.
E when listing processes, displays the environment variables used by each process.
– f displays the uid, PPIP, C, and stime fields.
F displays the tree structure with ASCII characters to express the relationship between processes.
– G < group name > this parameter has the same effect as the “- G” parameter. It can also be specified by the name of the phase operation leader.
G shows all processes under the current terminal, including the process of group leader.
– G < group ID > list the status of the processes belonging to the group, or use the group name to specify.
H do not display the title column.
– H displays a tree structure representing the relationships between processes.
– J or j displays the process status in the format of work control.
– L or l displays the process status in a detailed format.
L lists information about the field.
– m or m shows all threads.
N number the user and wchan fields.
– N shows all processes except those under the PS instruction terminal.
– P < process ID > specifies the process ID and lists the status of the process.
P < process ID > the effect of this parameter is the same as the specified “- P” parameter, only slightly different in list format.
R only processes with row terminals running are listed.
– s < phase job > specifies the process ID of the phase job and lists the status of the process that belongs to the phase job.
S displays the process status in the format of process signal.
S lists the process, including the data of the interrupted subprocesses.
– T < terminal number > specifies the terminal number and lists the status of the processes belonging to that terminal.
T < terminal No. > the effect of this parameter is the same as the specified “- t” parameter, only slightly different in list format.
– t shows all processes under the current terminal.
– U < user ID > this parameter has the same effect as the “- U” parameter specified.
U displays the process status in a user-oriented format.
– U < user ID > lists the status of the processes belonging to the user, which can also be specified by the user name.
U < user name > lists the status of the processes that belong to that user.
V displays the process status in the form of virtual memory.
– V or V displays version information.
– W or W displays the process status in a wide format.  
X shows all processes, not distinguished by terminals.
X uses the old Linux i386 login format to display the process status.
When – y is used with the parameter “- L”, the f (flag) field is not displayed, and the addr field is replaced by the RSS field
– < process ID > this parameter has the same effect as the specified “P” parameter.
— cols < characters per column > set the maximum characters per column.
— columns < characters per column > this parameter has the same effect as the “- columns” parameter.
— cumulative this parameter has the same effect as the specified “s” parameter.
— deselect this parameter has the same effect as the specified “- n” parameter.
— forest this parameter has the same effect as the specified “F” parameter.
— headers repeat the header column.
— help online help.
— info displays troubleshooting information.
— lines < number of display columns > set the number of columns in the display screen.
— no headers the effect of this parameter is the same as that of the specified “H” parameter, only slightly different in list format.
— group < group name > this parameter has the same effect as the specified “- G” parameter.
— group < group ID > this parameter has the same effect as the specified “- G” parameter.
— PID < process ID > this parameter has the same effect as the specified “- P” parameter.
— rows < display columns > this parameter has the same effect as the “- lines” parameter.
— Sid < phase job > this parameter has the same effect as the “- s” parameter specified.
— TTY < terminal number > this parameter has the same effect as the “- t” parameter specified.
— user < user name > this parameter has the same effect as the specified “- U” parameter.
— user < user ID > this parameter has the same effect as the specified “- U” parameter.
— version this parameter has the same effect as the specified “- V” parameter.
— width < characters per column > this parameter has the same effect as the “- cols” parameter specified.

Example 1

Copy code

The code is as follows:

[root @ localhost ~] (PS – E) show all processes
PID TTY TIME CMD
1 ? 00:00:00 init
2 ? 00:00:00 migration/0
3 ? 00:00:00 ksoftirqd/0
4 ? 00:00:00 watchdog/0
5 ? 00:00:00 migration/1
6 ? 00:00:00 ksoftirqd/1
…..
Copy code

The code is as follows:

[root @ localhost ~] ා񖓿ාාාා񖓿ා񖓿񖓿񖓿񖓿񖓿设设设设
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 4535 0.0 0.5 64340 11208 ? S 18:59 0:00 /usr/libexec/notification-daemon
root 4538 2.8 0.4 51116 8712 pts/2 SL+ 18:59 0:44 mplayer /mnt/usb/music/20080625211631.mp3 /mnt/usb/music/46250194.mp3 /mnt
root 4568 0.6 1.1 99516 24752 ? S 19:05 0:07 gedit file:///root/Desktop/csf
root 4624 0.0 0.0 5888 1476 pts/3 Ss 19:13 0:00 bash
root 4693 6.3 0.7 60096 15612 ? SN 19:25 0:00 /usr/bin/python -tt /usr/libexec/yum-updatesd-helper –check –dbus
…..
Copy code

The code is as follows:

[root @ localhost ~] ා PS – EF ා display uid, PPIP, C and stime fields of all processes
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 18:24 ? 00:00:00 init [3]
root 2 1 0 18:24 ? 00:00:00 [migration/0]
root 3 1 0 18:24 ? 00:00:00 [ksoftirqd/0]
root 4 1 0 18:24 ? 00:00:00 [watchdog/0]
root 5 1 0 18:24 ? 00:00:00 [migration/1]
……
Copy code

The code is as follows:

[root @ localhost ~] (PS – display all processes of the Zhangy user
PID TTY TIME CMD
3804 ? 00:00:00 httpd
3805 ? 00:00:00 httpd
3806 ? 00:00:00 httpd
3807 ? 00:00:00 httpd
3808 ? 00:00:00 httpd
3809 ? 00:00:00 httpd
3810 ? 00:00:00 httpd
3811 ? 00:00:00 httpd

Example 2

Copy code

The code is as follows:

#PS axo PID, comm, pcpu / / view the PID, name, and CPU usage of the process
#PS axo PID, comm, pcpu — sort = pcpu / / the sort parameter takes pcpu as the object pair

Example 3

Copy code

The code is as follows:

[root @ localhost ~] ා PS – ef| grep rpc.rstatd ා find rpc.rstatd process
root 28817 21271 0 15:14 pts/0 00:00:00 grep rpc.rstatd

Example 4

Copy code

The code is as follows:

#PS – EFL – view threads

Example 5

Copy code

The code is as follows:

#PS – E – O “% C:% P:% Z:% a” | sort – K5 – NR ා view processes and arrange by memory usage size

gitps

The gitps command is used to display the process status and has a visual interface, which is more convenient for operation

A show all process information
C shows only the real name of the process
E display environment variables
F shows the relationship between processes
N in figures
V display in the form of virtual memory
X terminal insensitive

U < user > specify user
P < process No. > specify process
T < terminal > designated terminal

Example:

Copy code

The code is as follows:

[root @ localhost Download] ා gitps – a ා show all processes

Recommended Today

Jupyterlab environment of tensorflow

Tensorflow prepares jupyterlab interactive notebook environment, which is convenient for us to write code and take notes at the same time. Basic environment The following is the basic environment of this article, do not detail the installation process. Ubuntu Ubuntu 18.04.5 LTS (Bionic Beaver) ubuntu-18.04.5-desktop-amd64.iso CUDA CUDA 11.2.2 cuda_11.2.2_460.32.03_linux.run cuDNN 8.1.1 libcudnn8_8.1.1.33-1+cuda11.2_amd64.deb libcudnn8-dev_8.1.1.33-1+cuda11.2_amd64.deb libcudnn8-samples_8.1.1.33-1+cuda11.2_amd64.deb Anaconda […]