ps — Return the status of a process

ps [–Aacdefjln] [–G idlist] [–g grouplist] [–n name]
[–o format] ...
[–p proclist] [–s idlist] [–t termlist] [–U|u uidlist]

Purpose

ps displays information about processes, provided that you have appropriate privileges to obtain information about the requested processes.

ps accepts several options. When a description says that ps lists all processes, it means all the processes in your virtual machine, provided that you have appropriate privileges.

Options

–A
Displays information on all accessible processes. You cannot specify both –a and –A.
–a
Displays information on all processes associated with terminals. You cannot specify both –a and –A.
–c
Displays more detailed information about processes for the –f and –l options. –c is accepted but not currently implemented.
–d
Displays information for all processes except group leaders.
–e
Displays information on all accessible processes.
–f
Displays information as if the user specified:
–o ruser=UID,pid,ppid,stime,tty=TTY,atime,args
–G idlist
Displays information on processes with group ID numbers in idlist. Separate the numbers in idlist with either blanks or commas.
–g grouplist
Displays information on processes with real group ID numbers in grouplist. Separate numbers in grouplist with either blanks or commas.
–j
Displays information as if the user specified:
–o pid,sid,pgid=PGRP,tty=TTY,atime,args
–l
Displays information as if the user had specified:
–o state,ruid=UID,pid,ppid,nice,vsz=SZ,tty=TTY,atime,comm=COMD
–o format
Displays information according to the given format specifications. For further information, see Format Specifications.
–n name
Specifies the name of the executable file containing the kernel symbol table.
–p proclist
Displays information for processes with process ID numbers in proclist. Separate numbers in proclist with commas.
–s idlist
Displays information for processes with session ID numbers in idlist. Separate the numbers in idlist with commas.
–t termlist
Displays information for processes with terminals in termlist. You denote terminals in termlist with either the file name of the device (for example, tty04), or if the file name begins with tty. For example, tty04 and 04 both denote the same terminal. Terminals in termlist are separated by either blanks or commas.
–U userlist
Displays information for processes with user IDs in userlist. Items in userlist can be user ID numbers or login names, and are separated by commas.
Note: A user can only view processes in their own virtual machine.
–u userlist
Displays information for processes with user IDs in userlist. Items in userlist can be user ID numbers or login names, and are separated by commas.

Format Specifications

The format specified with –o is a list of names separated with blanks or commas. At the beginning of the output display, ps displays column headings to tell you what you are seeing. For example, if you specify ruser (indicating that you want to see real user names), ps normally puts the heading RUSER at the top of the column that shows real user names.

If you do not specify the –o option, ps displays the information as though you had specified:
-o pid,tty=TTY,time,comm
The following list shows the names that ps recognizes. At the end of each description, we put the default column heading inside square brackets.
args
Displays the command that is running, with all its arguments. [COMMAND]
comm
Displays the name of the command that is running. This string is padded on the right if necessary. [COMMAND]
etime
Displays the amount of real time that has elapsed since the process began running. ps shows the time in the form:
[[dd-]hh:]mm:ss
where dd is the number of days, hh is the number of hours, mm is the number of minutes, and ss is the number of seconds. [ELAPSED]
group
Displays the effective group ID of the process, as a group name if possible and as a decimal group ID if not. [GROUP]
nice
Displays the nice value (urgency) of the process as a decimal value. [NI]
pcpu
Displays a percentage value giving the ratio of processor time used to processor time available. [%CPU]
pgid
Displays the process group ID as a decimal value. [PGID]
pid
Displays the process ID as a decimal value. Decimal pids are reported with default actions. [XPID]
ppid
Displays the parent process ID as a decimal value. [PPID]
rgroup
Displays the real group ID of the process, as a group name if possible and as a decimal group ID if not. [RGROUP]
ruser
Displays the real user ID of the process, as a user name if possible and as a decimal user ID otherwise. [RUSER]
time
Displays the amount of processor time that the process has used since it began running. ps displays this time in form similar to that used by etime. [TIME]
tty
Displays the name of the controlling terminal (if any). [TT]
user
Displays the effective user ID of the process, as a user name if possible and as a decimal user ID otherwise. [USER]
vsz
Displays the amount of (virtual) memory that the process is using, as a decimal number of kilobytes. [VSZ]
xpgid
Displays the process group ID as a hexadecimal value. [XPGID]
xpid
Displays the process ID as a hexadecimal value. [XPID]
xppid
Displays the parent process ID as a hexadecimal value. [XPPID]
The following names are extensions to ps:
addr
Displays the address of the process. [ADDR]
atime
Displays the abbreviated processor time of the process. [TIME]
flags
Displays the process flags. [F]
gid
Displays the effective group ID of the process. [EGID]
pri
Displays the process priority. [PRI]
rgid
Displays the real group ID of the process. [GID]
ruid
Displays the real user ID of the process. [UID]
sid
Displays the session ID of the process. [SID]
state
Displays the process state. [STATE] Various values can be printed in this field:
K
Kernel wait (for example, pause or sigsuspend).
R
Running (not kernel wait).

Both of these values will be prefixed with M to denote the fact that the processes are potentially multithreaded.

stime
Displays the start time of the process. [STIME]
uid
Displays the effective user ID of the process. [EUID]
wchan
Displays the channel upon which the process is waiting. [WCHAN]
If you want to specify your own column heading instead of using the defaults, put:
=heading
after the name in the format list. For example:
ps -o args,ruser=WHO
displays the command and the real user name. The heading for the command column is the default COMMAND, but the heading for the user name column is WHO. If you specify = with no heading, ps displays that column without a heading. If all columns have no heading, ps displays no heading line.

Environment Variables

ps uses the following environment variable:
COLUMNS
Contains the maximum number of columns to display on one line.

Localization

ps uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • LC_TIME
See Localization for more information.

Exit Values

Possible exit status values are:
0
Successful completion
1
Failure due to the inability to open the process table
2
Failure due to any of the following:
  • Unknown command-line option
  • Missing format string after –o
  • Missing lists after other options
  • Too many arguments on the command line

Portability

POSIX.2.

The –c, –d, –e, –f, –g, –j, –l, –n, –s, and –u options are extensions of the POSIX standard.

Related Commands

jobs, kill