# Linux commands: ps

> Learn how the Linux ps command lists running processes, how ps ax shows them all, and how to read columns like PID and STAT or filter the output with grep.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-09-06 | Topics: [CLI](https://flaviocopes.com/tags/cli/) | Canonical: https://flaviocopes.com/linux-command-ps/

Your computer is running, at all times, tons of different processes.

You can inspect them all using the `ps` command:

![Terminal output showing ps command results with PID, TTY, TIME and CMD columns displaying fish shell processes and hugo serve](https://flaviocopes.com/images/linux-command-ps/Screen_Shot_2020-09-02_at_12.25.08.png)

This is the list of user-initiated processes currently running in the current session.

Here I have a few `fish` shell instances, mostly opened by VS Code inside the editor, and an instances of Hugo running the development preview of a site.

Those are just the commands assigned to the current user. To list **all** processes we need to pass some options to `ps`.

The most common I use is `ps ax`:

![Terminal showing ps ax output with system processes including launchd, syslogd, and various system daemons with their PIDs and status](https://flaviocopes.com/images/linux-command-ps/Screen_Shot_2020-09-02_at_12.26.00.png)

> The `a` option is used to also list other users processes, not just our own. `x` shows processes not linked to any terminal (not initiated by users through a terminal).

As you can see, the longer commands are cut. Use the command `ps axww` to continue the command listing on a new line instead of cutting it:

![Terminal output of ps axww showing full command paths that wrap to new lines instead of being truncated](https://flaviocopes.com/images/linux-command-ps/Screen_Shot_2020-09-02_at_12.30.22.png)

> We need to specify `w` 2 times to apply this setting, it's not a typo.

You can search for a specific process combining `grep` with a pipe, like this:

```bash
ps axww | grep "VS Code"
```

![Terminal showing grep filtering ps output to display only Visual Studio Code processes with their long command arguments](https://flaviocopes.com/images/linux-command-ps/Screen_Shot_2020-09-02_at_12.33.45.png)

The columns returned by `ps` represent some key information.

The first information is `PID`, the process ID. This is key when you want to reference this process in another command, for example to kill it.

Then we have `TT` that tells us the terminal id used.

Then `STAT` tells us the state of the process:

`I` a process that is idle (sleeping for longer than about 20 seconds)
`R` a runnable process
`S` a process that is sleeping for less than about 20 seconds
`T` a stopped process
`U` a process in uninterruptible wait
`Z` a dead process (a _zombie_)

If you have more than one letter, the second represents further information, which can be very technical.

It's common to have `+` which indicates the process is in the foreground in its terminal. `s` means the process is a [session leader](https://unix.stackexchange.com/questions/18166/what-are-session-leaders-in-ps).

`TIME` tells us how long the process has been running.

> This command works on Linux, macOS, WSL, and anywhere you have a UNIX environment
