FactorPad
Faster Learning Tutorials

Linux ps command summary with examples

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.
Paul Alan Davis, CFA, October 24, 2016
Updated: August 2, 2018
In this tutorial, 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 Next

~/ home  / tech  / linux essentials  / ps command


The Linux ps command

Beginner

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

Video Tutorial

Linux ps command summary with examples (3:36)

Videos can also be accessed from the YouTube Playlist.

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.

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?

Click here to join our growing YouTube Channel.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the crontab command, hit Back.
  • To dig deeper into how the system works with the printenv command, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / ps command



 
 
Keywords:
linux ps command
linux processes
view processes in linux
ps unix
linux pid
process id linux
show processes in linux
linux list jobs
linux process list
show running processes in linux
linux running processes
ps ax
ps aux
linux ps examples
kill process linux
list pid
linux ps tutorial
man ps
linux show processes