ps command

LINUX-Frequently used commands

ps command View and check the status of processes at a glance.
Syntax
ps   [Option]
The ps command is used to list and check the status of processes.
If you run it without options, it will only show you the processes it has run itself.
You can also view other users and daemon processes with the option.
Frequently used options
-ADisplays all processes.
-NDisplays processes that do not meet the specified criteria.
TShows all processes on the terminal you are logged in to
-aShows all processes except the session leader process and the process without a terminal.
aDisplays the processes of all users.
-dShows all processes except the session leader.
-eDisplays all processes.
gDisplays all processes.
rDisplays the running processes.
xDisplays the daemon process.
-C <Command name>Displays the process with the specified command name.
-G <Real group ID>
-G <Real group name> 
–Group <Real group ID>
–Group <Real group name> 
Displays the processes belonging to the specified real group ID or real group name.
-g <Session ID>
-g ,Group ID>
Displays the processes belonging to the specified session ID or group ID.
-u <Real User ID>
U <Real User ID>
-U <Real User ID>
–User <Real User ID>
-u <Real user name>
U <Real user name>
-U <Real user name>
–User <Real user name>
Displays the processes belonging to the specified real user ID (RUID) or effective user name.
–group <Effective Group ID>
–group <Effective group name>
Displays the processes belonging to the specified effective group ID (EGID) or effective group name.
p <Process ID>
-p <Process ID>
–pid <Process ID>
Displays the process with the specified process ID.
–ppid <Parent process ID>Displays the processes belonging to the specified parent process.
-s <Session ID>
–sid <Session ID>
Displays the processes belonging to the specified session ID.
t <Terminal ID>
-t <Terminal ID>
–tty <Terminal ID>
Displays the processes belonging to the specified terminal ID.
–user <User ID>
–user <User name>
Displays the processes belonging to the specified user name or user ID.
-123Session ID “123” is displayed.
123PID “123” is displayed.
-FChange the display format
The headers displayed are “UID”, “PID”, “PPID”, “C”, “SZ”, “RSS”, “PSR”, “STIME”, “TTY”, “TIME” and “CMD”.
-O formatAdds the keys ‘pid’, ‘format’, ‘state’, ‘tname’, ‘time’ and ‘command’ to the specified user-defined format.
For a user-defined format, see the “-o” option.
O formatAdds ‘pid’, ‘s’, ‘tty’, ‘time’ and ‘command’ to the specified user-defined format.
For a user-defined format, see the “-o” option.
XChange the display format
The headers displayed will be “LABEL”, “PID”, “TTY”, “TIME” and “CMD”.
Z , -MChange the display format
The headers displayed will be “PID”, “STACKP”, “ESP”, “EIP”, “TMOUT”, “ALARM”, “STAT”, “TTY”, “TIME” and “COMMAND”.
-cChange the display format
The headers displayed will be “PID”, “CLS”, “PRI”, “TTY”, “TIME” and “CMD”.
-fChange the display format
The headers displayed will be “UID”, “PID”, “PPID”, “C”, “STIME”, “TTY”, “TIME” and “CMD”.
jChange the display format
The headers displayed will be “PPID”, “PID”, “PGID”, “SID”, “TTY”, “TPGID”, “STAT”, “UID”, “TIME” and “COMMAND”.
-jChange the display format
The headers displayed will be “PID”, “PGID”, “SID”, “TTY”, “TIME” and “CMD”.
Change the display format
The headers displayed will be “F”, “UID”, “PID”, “PPID”, “PRI”, “NI”, “VSZ”, “RSS”, “WCHAN”, “STAT”, “TTY”, “TIME” and “COMMAND”.
-lChange the display format
The headers displayed will be “FS”, “UID”, “PID”, “PPID”, “C”, “PRI”, “NI”, “ADDR”, “SZ”, “WCHAN”, “TTY”, “TIME” and “CMD”.
sChange the display format
The headers displayed are “UID”, “PID”, “PENDING”, “BLOCKED”, “IGNORED”, “CAUGHT”, “STAT”, “TTY”, “TIME” and “COMMAND”.
uChange the display format
The headers that will be displayed are USER, PID, %CPU, %MEM, VSZ, RSS, TTY, STAT, START, TIME and COMMAND.
vChange the display format
The headers displayed are PID, TTY, STAT, TIME, MAJFL, TRS, DRS, RSS, %MEM and COMMAND.
-yThe header “F” is not displayed.
o User-defined format, -o User-defined format,–format User-defined formatSpecifies a user-defined format. The user-defined format is created using the standard format specifiers.
Format key [key2 ・・・] or key[,key2]
–contextChange the display format.
The headers displayed are “PID”, “CONTEXT” and “COMMAND”.
-HView processes in a hierarchy.
O Sort bySpecify the sort order.
SInformation about dead child processes is added to the parent process.
cDisplay by executable name.
eDisplays the command name and environment variables.
fChange the display format
The headers displayed will be “UID”, “PID”, “PPID”, “C”, “STIME”, “TTY”, “TIME” and “CMD”.
hheader is not displayed.
k Sort format
–sort Sort format
Set the sorting method.
Sort format [Sort by]key[,[Sort by]key2 ・・・]
The order can be + (ascending) or – (descending).
The key is the one described in the standard format specifier.
The following keys cannot be used for sorting

c, cmd
Short name of executable file
C, pcpu
cpu usage
f, flags
Flag
g, pgrp
Group ID of the process
G, tpgid
Control terminal process group ID
j, cutime
Cumulative user time
J, cstime
Accumulated system time
k, utime
User time
m, min_flt
Number of minor page faults
M, maj_flt
Number of major page faults
n, cmin_flt
Cumulative number of minor page faults
N, cmaj_flt
Cumulative number of minor page faults
o, session
Session ID
p, pid
Process ID
P, ppid
Process ID of the parent process
r, rss
Size of resident set
R, resident
Number of resident pages
s, size
Memory size
S, share
The amount of pages occupied
t, tty
Device number of the control terminal
T, start_time
Time when the process was started
U, uid
User ID number
u, user
User name
v, vsize
Total size of virtual memory
y, priority
Kernel scheduling priority
-n File name , N File nameSpecifies the name list file for displaying WCHAN.
nWCHAN and USER are displayed as numerical values.
-w , WIncrease the width of the display.
–cols Number of digits ,
–columns Number of digits
Specify the width to display.
–cumulativeIt also shows dead child processes.
–forestA tree view of the process hierarchy.
–headersIf the page spans several pages, the header is displayed at the top.
–no-headersheader is not displayed.
–lines Number of digits ,
–rows Number of digits
Specify the number of lines to display.
–width Number of digitsSpecify the width to display.
HDisplay thread.
-LChange the display format
The headers displayed will be “PID”, “LWP”, “TTY”, “TIME” and “CMD”.
-TChange the display format
The headers displayed will be “PID”, “SPID”, “TTY”, “TIME” and “CMD”.
-m , mSet the thread to be displayed after the process.
LDisplays all format specifiers.
–helpDisplays usage instructions.
–infoDisplays debug information.
-v , V , –versionDisplays version information.
Example: View the process.
$ su – 
Password:
#  ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

root 1 0.0 0.0 10364 688 ? Ss Jun17 0:00 init [3]
root 2 0.0 0.0 0 0 ? S< Aug17 0:00 [migration/0]
root 3 0.0 0.0 0 0 ? SN Aug17 0:01 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S< Aug17 0:00 [watchdog/0]
root 5 0.0 0.0 0 0 ? S< Aug17 0:00 [events/0]


root 13039 0.0 0.1 90152 3340 ? Ss 13:18 0:00 sshd: koro [priv]
koro 13041 0.0 0.0 90152 1816 ? S 13:18 0:00 sshd: koro@pts/0
koro 13042 0.0 0.0 66104 1560 pts/0 Ss 13:18 0:00 -bash
root 13064 0.0 0.0 101108 1432 pts/0 S 13:18 0:00 su –
root 13065 0.0 0.0 66196 1664 pts/0 S 13:18 0:00 -bash
root 13115 0.0 0.0 65632 992 pts/0 R+ 13:21 0:00 ps aux
.
Information displayed.
S:Condition
・Field 1
R:Workable
T:Stopping or tracing
D:Dormant and uninterruptible
S:Dormant
Z:Zombies (not deleted but stopped)
・Field 2
W:Swap out (no resident pages)
・Field 3
N:Positive nice value
UID :User number of the executing user
PID :Number automatically assigned to each process
PPID :Process ID of the parent process
PRI :Priority of the process
NI :Nice value of the process
SZ :Size of the virtual memory image
RSS :Amount of physical memory in use
WCHAN :Kernel functions for process dormancy
PAGEIN:Number of major page faults
TRS :Amount of resident text
TTY :The control terminal running the process
TIME :CPU consumption time
CMD :Execute command
SWAP :Amount of swap devices
SHARE :使用中の共有メモリ量
タイトルとURLをコピーしました