Bird
Raised Fist0
Linux CLIscripting~10 mins

ps (list processes) in Linux CLI - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - ps (list processes)
Run 'ps' command
↓
System collects process info
↓
Display process list
↓
User reads output or pipes it
The 'ps' command asks the system to gather current process details and then shows them as a list.
Execution Sample
Linux CLI
ps
This command lists the current processes running in the terminal session.
Execution Table
StepActionSystem ResponseOutput Example
1User types 'ps' and presses EnterShell runs 'ps' command
2'ps' collects process info for current terminal sessionSystem gathers PID, TTY, TIME, CMD
3'ps' formats and prints the process listOutput shows columns PID, TTY, TIME, CMD PID TTY TIME CMD 1234 pts/0 00:00:00 bash 5678 pts/0 00:00:00 ps
4User reads the list or pipes it for further useProcess list is ready for viewing or scripting
5No more processes to list, command endsShell prompt returns
💡 'ps' finishes after listing current processes and returns control to the shell
Variable Tracker
VariableStartAfter Step 2After Step 3Final
Process Listemptycollected current session processesformatted for displaydisplayed to user
Outputnonenoneprocess info linesprinted on screen
Key Moments - 3 Insights
Why does 'ps' only show processes related to my terminal by default?
By default, 'ps' shows processes attached to your current terminal (TTY). This is why the output is limited, as seen in execution_table step 2 where it collects only current session processes.
What do the columns PID, TTY, TIME, and CMD mean in the output?
PID is the process ID number, TTY is the terminal associated, TIME is CPU time used, and CMD is the command name. This is shown in execution_table step 3 output example.
How can I see all processes, not just mine?
You can use options like 'ps aux' to list all processes. The basic 'ps' command shown here only lists your session's processes, as explained in the concept_flow.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what does 'ps' do at step 2?
ACollects process info for current terminal session
BPrints the process list on screen
CEnds the command and returns to shell
DWaits for user input
💡 Hint
Check the 'System Response' column in step 2 of execution_table
At which step does 'ps' display the process list?
AStep 2
BStep 3
CStep 1
DStep 5
💡 Hint
Look at the 'Output Example' column in execution_table
If you want to see all processes, not just your terminal's, what should you do?
AUse 'ps' with no options
BRestart the terminal
CUse 'ps aux' or similar options
DUse 'ps' and then press Enter twice
💡 Hint
Refer to key_moments where it explains how to see all processes
Concept Snapshot
ps command lists processes running in your terminal session
Syntax: ps
Shows columns: PID (process ID), TTY (terminal), TIME (CPU time), CMD (command)
Default shows only your session's processes
Use options like 'ps aux' to see all processes
Full Transcript
The 'ps' command is used to list processes running in your current terminal session. When you type 'ps' and press Enter, the system collects information about processes related to your terminal, including their process ID (PID), terminal (TTY), CPU time used (TIME), and the command name (CMD). This information is then displayed as a list. By default, 'ps' only shows processes attached to your terminal. To see all processes on the system, you can use options like 'ps aux'. The command finishes after printing the list and returns control to the shell prompt.

Practice

(1/5)
1. What does the ps command do in Linux?
easy
A. It shows the disk usage of files and folders.
B. It lists the currently running processes on the system.
C. It displays the network connections.
D. It updates the system software.

Solution

  1. Step 1: Understand the purpose of ps

    The ps command is used to show processes running on the system.
  2. Step 2: Compare with other options

    Disk usage is handled by du, network connections by netstat or ss, and software updates by apt or yum.
  3. Final Answer:

    It lists the currently running processes on the system. -> Option B
  4. Quick Check:

    ps shows running processes [OK]
Hint: Remember: ps = process status, shows running programs [OK]
Common Mistakes:
  • Confusing ps with disk or network commands
  • Thinking ps updates software
  • Assuming ps shows file sizes
2. Which of the following is the correct syntax to list all processes with full details using ps?
easy
A. ps -l
B. ps -xv
C. ps auxf
D. ps -ef

Solution

  1. Step 1: Identify the common option for full details

    The -ef option with ps lists all processes with full details.
  2. Step 2: Check other options

    ps -xv is an invalid combination, ps auxf displays a tree view rather than a plain list, and ps -l shows limited info for current processes.
  3. Final Answer:

    ps -ef -> Option D
  4. Quick Check:

    ps -ef shows all processes fully [OK]
Hint: Use ps -ef for full process list [OK]
Common Mistakes:
  • Using ps -xv which is invalid
  • Confusing ps auxf as a single option
  • Using ps -l which shows limited info
3. What will be the output of the command ps -e | grep sshd if the sshd process is running?
medium
A. It will show the sshd process details in the list.
B. It will show an error because grep cannot be used with ps.
C. It will show all processes except sshd.
D. It will show nothing because sshd is filtered out.

Solution

  1. Step 1: Understand ps -e and pipe to grep

    ps -e lists all processes; piping to grep sshd filters lines containing 'sshd'.
  2. Step 2: Interpret the output if sshd is running

    If sshd is running, its process line will appear in the output.
  3. Final Answer:

    It will show the sshd process details in the list. -> Option A
  4. Quick Check:

    ps -e | grep sshd shows sshd if running [OK]
Hint: Pipe ps output to grep to find specific processes [OK]
Common Mistakes:
  • Thinking grep causes error with ps
  • Assuming grep excludes matching lines
  • Believing sshd won't appear if running
4. You run ps -ef | grep but get an error. What is the likely cause?
medium
A. You forgot to provide a search pattern after grep.
B. The ps command does not support pipes.
C. The -ef option is invalid for ps.
D. grep cannot be used with ps output.

Solution

  1. Step 1: Analyze the command structure

    ps -ef outputs all processes; piping to grep requires a pattern to search.
  2. Step 2: Identify the error cause

    Without a pattern, grep throws an error because it expects a search term.
  3. Final Answer:

    You forgot to provide a search pattern after grep. -> Option A
  4. Quick Check:

    grep needs a pattern after it [OK]
Hint: Always give grep a pattern to avoid errors [OK]
Common Mistakes:
  • Thinking ps can't pipe output
  • Believing -ef is invalid
  • Assuming grep works without a pattern
5. You want to list all processes owned by user 'alice' with detailed info. Which command should you use?
hard
A. ps aux | grep alice
B. ps -ef | grep alice
C. ps -u alice -f
D. ps -U alice

Solution

  1. Step 1: Understand options for user filtering

    ps -u alice lists processes for user alice; -f adds full details.
  2. Step 2: Compare other options

    Using ps -ef | grep alice or ps aux | grep alice relies on grep which may match username in other fields, not just owner. ps -U alice lists processes by real user ID but lacks full details.
  3. Final Answer:

    ps -u alice -f -> Option C
  4. Quick Check:

    ps -u alice -f lists alice's processes fully [OK]
Hint: Use ps -u username -f for detailed user processes [OK]
Common Mistakes:
  • Using grep which may show unrelated lines
  • Using -U without details
  • Confusing -u and -U options
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard