📚 Knowledge Garden

Search

Search IconIcon to open search

ps

Last updated Aug 18, 2023

ps reports a list of the currently running processes.

Most versions accept unix, BSD and GNU style options.

# Installation

On most MacOS and Linux installations the ps command is already available. It can however be installed using the distributions package manager.

1
$ (apt-get install|apk add|yum install) procps

# Use Cases

# Show processes for the current user

1
2
3
$ ps
  PID TTY           TIME CMD
 2068 ttys001    0:00.64 /bin/zsh -l

# Show all processes

1
2
3
4
5
$ (ps -e | ps a)
  PID TTY           TIME CMD
 2068 ttys001    0:00.67 /bin/zsh -l
65418 ttys001    0:00.00 ps -e
13824 ttys002    0:00.12 /bin/zsh -l

# Show processes and include columns

You can print only specific columns if you wish to perform an action with the output like parsing with AWK or filtering with grep.

1
2
3
4
$ ps -o pid,comm   
  PID COMM
 2068 /bin/zsh
13824 /bin/zsh

For example to count the number of instances of zsh running for the current user.

1
2
$ ps -o comm | grep -c 'zsh'
2