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 | |
-A | Displays all processes. |
-N | Displays processes that do not meet the specified criteria. |
T | Shows all processes on the terminal you are logged in to |
-a | Shows all processes except the session leader process and the process without a terminal. |
a | Displays the processes of all users. |
-d | Shows all processes except the session leader. |
-e | Displays all processes. |
g | Displays all processes. |
r | Displays the running processes. |
x | Displays 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. |
-123 | Session ID "123" is displayed. |
123 | PID "123" is displayed. |
-F | Change the display format The headers displayed are "UID", "PID", "PPID", "C", "SZ", "RSS", "PSR", "STIME", "TTY", "TIME" and "CMD". |
-O format | Adds 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 format | Adds 'pid', 's', 'tty', 'time' and 'command' to the specified user-defined format. For a user-defined format, see the "-o" option. |
X | Change the display format The headers displayed will be "LABEL", "PID", "TTY", "TIME" and "CMD". |
Z , -M | Change the display format The headers displayed will be "PID", "STACKP", "ESP", "EIP", "TMOUT", "ALARM", "STAT", "TTY", "TIME" and "COMMAND". |
-c | Change the display format The headers displayed will be "PID", "CLS", "PRI", "TTY", "TIME" and "CMD". |
-f | Change the display format The headers displayed will be "UID", "PID", "PPID", "C", "STIME", "TTY", "TIME" and "CMD". |
j | Change the display format The headers displayed will be "PPID", "PID", "PGID", "SID", "TTY", "TPGID", "STAT", "UID", "TIME" and "COMMAND". |
-j | Change the display format The headers displayed will be "PID", "PGID", "SID", "TTY", "TIME" and "CMD". |
l | Change the display format The headers displayed will be "F", "UID", "PID", "PPID", "PRI", "NI", "VSZ", "RSS", "WCHAN", "STAT", "TTY", "TIME" and "COMMAND". |
-l | Change the display format The headers displayed will be "FS", "UID", "PID", "PPID", "C", "PRI", "NI", "ADDR", "SZ", "WCHAN", "TTY", "TIME" and "CMD". |
s | Change the display format The headers displayed are "UID", "PID", "PENDING", "BLOCKED", "IGNORED", "CAUGHT", "STAT", "TTY", "TIME" and "COMMAND". |
u | Change the display format The headers that will be displayed are USER, PID, %CPU, %MEM, VSZ, RSS, TTY, STAT, START, TIME and COMMAND. |
v | Change the display format The headers displayed are PID, TTY, STAT, TIME, MAJFL, TRS, DRS, RSS, %MEM and COMMAND. |
-y | The header "F" is not displayed. |
o User-defined format, -o User-defined format,--format User-defined format | Specifies a user-defined format. The user-defined format is created using the standard format specifiers. Format key [key2 ・・・] or key[,key2] |
--context | Change the display format. The headers displayed are "PID", "CONTEXT" and "COMMAND". |
-H | View processes in a hierarchy. |
O Sort by | Specify the sort order. |
S | Information about dead child processes is added to the parent process. |
c | Display by executable name. |
e | Displays the command name and environment variables. |
f | Change the display format The headers displayed will be "UID", "PID", "PPID", "C", "STIME", "TTY", "TIME" and "CMD". |
h | header 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
|
-n File name , N File name | Specifies the name list file for displaying WCHAN. |
n | WCHAN and USER are displayed as numerical values. |
-w , W | Increase the width of the display. |
--cols Number of digits , --columns Number of digits |
Specify the width to display. |
--cumulative | It also shows dead child processes. |
--forest | A tree view of the process hierarchy. |
--headers | If the page spans several pages, the header is displayed at the top. |
--no-headers | header is not displayed. |
--lines Number of digits , --rows Number of digits |
Specify the number of lines to display. |
--width Number of digits | Specify the width to display. |
H | Display thread. |
-L | Change the display format The headers displayed will be "PID", "LWP", "TTY", "TIME" and "CMD". |
-T | Change the display format The headers displayed will be "PID", "SPID", "TTY", "TIME" and "CMD". |
-m , m | Set the thread to be displayed after the process. |
L | Displays all format specifiers. |
--help | Displays usage instructions. |
--info | Displays debug information. |
-v , V , --version | Displays 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 :使用中の共有メモリ量 |