"ps" - Process Status Command

This section provides a tutorial example on how to use the 'ps' command to display running processes with specified conditions and columns.

What Is the "ps" Command? - The "ps", process status, command displays a list of running processes that matches given conditions. You can also control what information to be displayed for each process.

Here are some examples of using the "ps" command on my macOS computer.

1. Display my own processes that have controlling terminals.

herong$ ps
  PID TTY           TIME CMD
  806 ttys000    0:00.97 -bash
  815 ttys001    0:00.02 -bash
21716 ttys001    0:00.01 man ps
21717 ttys001    0:00.00 sh -c (cd '/usr/share/man' ...
21718 ttys001    0:00.00 sh -c (cd '/usr/share/man' ...
21723 ttys001    0:00.00 sh -c (cd '/usr/share/man' ...
21724 ttys001    0:00.00 /usr/bin/less -is
  828 ttys002    0:00.01 -bash
  835 ttys003    0:00.02 -bash
  842 ttys004    0:00.03 -bash
  849 ttys005    0:00.04 -bash
19827 ttys005    0:00.00 -bash
19828 ttys005    0:00.09 ssh herong@192.168.1.10

2. Display all processes ("-A" option) in long format ("-l" option).

herong$ ps -Al | more
UID PID PPID       F CPU PRI NI      SZ   RSS WCHAN   S ADDR TTY     TIME CMD
  0   1    0    4004   0  37  0 2543224 19276 -     Ss      0 ?? 10:52.31 /sbin/launchd
  0  39    1    4004   0  37  0 2549892  6416 -     Ss      0 ??  1:23.10 /usr/libexec/User...
  0  40    1    4004   0   4  0 2515384   888 -     Ss      0 ??  0:07.99 /usr/sbin/syslogd
  0  42    1    4004   0  20  0 2506256   468 -     Ss      0 ??  0:12.88 /System/Library/P...
  0  43    1    4004   0  37  0 2545756 11564 -     Ss      0 ??  0:50.50 /usr/libexec/kext...
  0  44    1 1004004   0  50  0 3005392  3268 -     Ss      0 ??  1:47.85 /System/Library/F...
  0  46    1    4004   0   4  0 2541560  3072 -     Ss      0 ??  0:08.99 /System/Library/P...
 55  49    1    4004   0   4  0 2544344  1624 -     Ss      0 ??  0:02.55 /System/Library/C...
  0  50    1    400c   0  37  0 2551844  6720 -     Ss      0 ??  0:30.97 /usr/libexec/conf...
  0  51    1    4004   0  20  0 2689516 56564 -     Ss      0 ??  8:00.41 /Applications/Exp...
  0  52    1    400c   0  37  0 2540128  2952 -     Ss      0 ??  0:25.85 /System/Library/C...
  0  53    1    4004   0   4  0 2554296 15148 -     Ss      0 ??  0:04.35 /usr/libexec/mobi...
  0  58    1    4004   0  37  0 2703648 20780 -     Ss      0 ?? 22:18.04 /usr/libexec/logd
  0  62    1    4004   0  37  0 2548800  8452 -     Ss      0 ??  2:22.19 /usr/libexec/airp...
  0  64    1    4004   0  37 10 2522840  1296 -     SNs     0 ??  0:02.09 /usr/libexec/warm...
...

3. Display processes with specified columns ("-o pid,user,..." option) and sort by CPU ("-r" option).

herong$ ps -A -o pid,user,%cpu,%mem,command -r
  PID USER          %CPU %MEM COMMAND
  174 _coreaudiod    4.0  0.0 /usr/sbin/coreaudiod
  804 herong         2.6  1.1 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal
  138 _windowserver  2.4  0.8 /System/Library/PrivateFrameworks/SkyLight.framework/Resourc...
  105 _hidd          2.1  0.0 /usr/libexec/hidd
  751 herong         0.9  0.4 /Applications/Atom.app/Contents/MacOS/Atom
 9960 herong         0.4  1.6 /Applications/Microsoft Remote Desktop.app/Contents/MacOS/Mi...
65721 _mysql         0.3  0.0 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/loc...
23251 herong         0.1  0.7 /System/Library/StagedFrameworks/Safari/WebKit.framework/Ver...
23300 herong         0.1  0.8 /System/Library/StagedFrameworks/Safari/WebKit.framework/Ver...
...

Table of Contents

 About This Book

 Macintosh OS (Operating System) History

 macOS Operating System

 macOS File Systems

 macOS Network Connections

System and Application Processes

 What Is a Running Process

 Use Activity Monitor on macOS

"ps" - Process Status Command

 "top" - Display Top Processes

 "nettop" - Processes Top Network Usages

 "Finder" Process - File Browser on Mac

 "WindowServer" Process - Drawing Graphics on Screen

 "Dock" Related Processes

 "Siri" Processes - Voice Command Interpreter

 "mds" Processes - Metadata Server and Spotlight

 "spindump" Processes - Dump Memory Contents

 "login" Processes - Login Window and Services

 "softwareupdate" Processes - Update System and Apps

 "TeamsUpdater" Process from Microsoft Teams

 Keychain Access - Password Manager

 Keychain Access - Certificate Manager

 Productivity Tools on macOS

 Programming Tools on macOS

 Apache Web Server on macOS

 Develop and Run Java Applications

 Full Version in PDF/EPUB