← Back to Bash Course | Chapter 10: Text Processing Tools | Lesson 1 of 12

The ps Command

ps is like a class roll call that lists every program currently running, each with its own ID number, so you know who is up and about on your computer.

In this page:

  1. The ps Command
Syntax
bash
ps [options]
ps -p process_id

The ps Command

ps lists currently running processes, showing information like process ID (PID), status, and the command that started them. ps aux is a common invocation showing all processes for all users with detailed columns.

It's the primary tool for inspecting what's running on a system.

Note:
  • Pipe ps aux into grep to find a specific process by name, e.g.
  • ps aux | grep myscript.

Example: The ps Command

bash
#!/bin/bash
echo "Current shell's PID: $$"
ps -p $$
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Using ps aux | grep name and matching the grep process itself.
  2. Forgetting that ps options differ between systems.
  3. Parsing the default ps output in scripts, when ps -o pid,comm gives stable columns.
🔒

Chapter Quiz — Complete all 12 topics to unlock

0/12 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.