Skip to content

Linux commands: ps

A quick guide to the `ps` command, used to list the processes currently running in the system

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

You can inspect them all using the ps command:

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:

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:

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:

ps axww | grep "VS Code"

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.

TIME tells us how long the process has been running.

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


→ Get my Linux Command Line Handbook

download all my books for free

  • javascript handbook
  • typescript handbook
  • css handbook
  • node.js handbook
  • astro handbook
  • html handbook
  • next.js pages router handbook
  • alpine.js handbook
  • htmx handbook
  • react handbook
  • sql handbook
  • git cheat sheet
  • laravel handbook
  • express handbook
  • swift handbook
  • go handbook
  • php handbook
  • python handbook
  • cli handbook
  • c handbook

subscribe to my newsletter to get them

Terms: by subscribing to the newsletter you agree the following terms and conditions and privacy policy. The aim of the newsletter is to keep you up to date about new tutorials, new book releases or courses organized by Flavio. If you wish to unsubscribe from the newsletter, you can click the unsubscribe link that's present at the bottom of each email, anytime. I will not communicate/spread/publish or otherwise give away your address. Your email address is the only personal information collected, and it's only collected for the primary purpose of keeping you informed through the newsletter. It's stored in a secure server based in the EU. You can contact Flavio by emailing flavio@flaviocopes.com. These terms and conditions are governed by the laws in force in Italy and you unconditionally submit to the jurisdiction of the courts of Italy.

Related posts about cli: