The ps Command

The ps command is inconsistent between different flavors of Unix. The System V Unices use the normal dash (-) symbol to mark options, so ps -eaf is a common command to list all current processes, while BSD Unices do not, and also recognize different switches; ps aux is a common way to list all current processes on a BSD system. As is often the case, GNU/Linux straddles both traditions, and the GNU implementation of ps accepts System V and BSD options, as well as its own GNU options, such as --user. System V is probably the most widely used format, and the System V style is used in this chapter.

ps -fp 3010
UID        PID  PPID  C STIME TTY          TIME CMD 
mysql     3010  2973  0 Oct24 ?        00:11:23 /usr/sbin/mysqld --basedir=/usr --d
atadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-ext
ernal-locking --port=3306 

The headings are a little cryptic; UID, PID, and PPID are the Username, Process ID, and Parent PID, respectively. STIME is the time (or date) that the process was started. If associated with a terminal, the terminal is reported under TTY. TIME is the amount of CPU time that the process has used, and CMD is the full name of the executable. C is a rough figure to represent the percentage of CPU time the process is responsible for consuming.

note.ai

Many ps options can be selected on the command line; to display all processes ...

Get Shell Scripting: Expert Recipes for Linux, Bash, and More now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.