FactorPad
Build a Better Process

Linux ps Command Summary with Examples

Linux ps allows you to print a snapshot of current processes.
  1. Purpose - Learn what ps is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with ps.
  4. A tip - Finish off with one more insight.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
In this tutorial on Linux ps, 45 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / ps-command.html


An ad-free and cookie-free website.


Examples of the Linux ps Command

Beginner

Learn to list and modify running jobs at the Linux command line.

Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux ps Command Summary with Examples (3:36)

Video Script

The Command and Why You Need It

Our forty-fifth word, or command to memorize is ps from our category System.

ps allows you to print a snapshot of current processes.

Common Linux ps Options
-options description
--help Print help screen
T Pring basic list on current terminal
X Print extensive list beyond current terminal

Recall that we just covered automating commands, and now we'll be able to monitor the system behind the scenes.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The ps command has over 40 options and there really aren't arguments per se, just a whole slew of options, and I'll prevent us from getting into minutiae here, and keep it very basic.

Like most commands, help is available with double-dash --help and it's multi-layered, making it very, for lack of a better word, helpful.

The T option shows processes in the current terminal session, and X goes beyond that. These are capital letters on my version of ps and I should mention other versions: Unix, BSD and GNU may differ.

So why is ps an important command? Well, not only for security is it important to monitor the system, but you may need to intervene now and again. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. Let's look at the multi-layered help system, typing ps --help.

$ ps --help Usage: ps [options] Try 'ps --help <simple|list|output|threads|misc|all>' or 'ps --help <s|l|o|t|m|a>' for additional help text. For more details see ps(1).

Which provides other options, like ps --help simple.

$ ps --help simple Usage: ps [options] Basic options: -A, -e all processes -a all with tty, except session leaders a all with tty, including other users -d all except session leaders -N, --deselect negate selection r only running processes T all processes on this terminal x processes without controlling ttys For more details see ps(1). $ clear

As you can see here, and then last, let's type ps T.

$ ps T PID TTY STAT TIME COMMAND 1017 pts/1 Ss 0:00 -bash 1094 pts/1 R+ 0:00 ps T

And there are two processes running, bash and ps. PID is the process ID number, TTY is the terminal, STAT is the status, here it's sleeping or running, but there are more, and TIME is the time spent on the CPU.

A Final Tip

Okay now you know how to use ps. And you know the syntax for commands, options and arguments.

One last tip about the ps command. So if you want a constantly updating version of ps, try the top command, especially if you are a very curious person. Everyone should try it at least once in their lives. Oh, letter q is the safe word that gets you out of the top program.

Okay, thanks for visiting today. I hope this was a helpful introduction to the ps command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

Don't lose sight of this growing educational site which can improve your career materially. Three ways to stay connected, subscribe at YouTube, follow @factorpad on Twitter and join our no-spam email list.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / ps-command.html


linux ps command
ps linux
linux ps
ps aux
unix ps
ps unix
linux ps examples
list processes linux
linux pid
linux show processes
linux running processes
ps ax
linux show processes
linux list jobs
list pid
linux ps tutorial
man ps
process id linux

A newly-updated free resource. Connect and refer a friend today.