惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Exploit Database - CXSecurity.com
V
Vulnerabilities – Threatpost
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
I
Intezer
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News | PayPal Newsroom
S
Security Affairs
T
Tor Project blog
P
Proofpoint News Feed
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Security @ Cisco Blogs
H
Heimdal Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
Help Net Security
Help Net Security
U
Unit 42
云风的 BLOG
云风的 BLOG
The Hacker News
The Hacker News
Cisco Talos Blog
Cisco Talos Blog
量子位
F
Full Disclosure
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 叶小钗
有赞技术团队
有赞技术团队
T
Troy Hunt's Blog
P
Privacy & Cybersecurity Law Blog
Forbes - Security
Forbes - Security
人人都是产品经理
人人都是产品经理
L
Lohrmann on Cybersecurity
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Security Blog
Microsoft Security Blog
博客园 - Franky
腾讯CDC
AI
AI
Last Week in AI
Last Week in AI
Latest news
Latest news
Google Online Security Blog
Google Online Security Blog
N
Netflix TechBlog - Medium
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
Martin Fowler
Martin Fowler
Blog — PlanetScale
Blog — PlanetScale
V2EX - 技术
V2EX - 技术
酷 壳 – CoolShell
酷 壳 – CoolShell

DigitalOcean Community Tutorials

Mastering grep with Regular Expressions for Efficient Text Search It's Time to Break Up with Your Cloud: Why AI Teams are Switching We Built a Private-Document AI App to Test Platform Security. Here Is What We Could Actually Verify. PostgreSQL Explained: A Complete Beginner-to-Advanced Guide How To Install and Configure Postfix on Ubuntu How To Build a Web Application Using Flask in Python 3 Build AI Reading List with DigitalOcean Functions and Mistral How To Concatenate Strings in Python How to Allow MySQL Remote Access Securely How To Install and Use Docker on Rocky Linux How To Build a Multi-Agent AI System with Docker Agent DSPy Use Cases: Build Optimized LLM Pipelines How To Submit AJAX Forms with jQuery Build an AI-Powered GPU Fleet Optimizer with the DigitalOcean AI Platform ADK Monitor GPU Utilization in Real Time: A Complete Guide Reduce File Size of Images in Linux - CLI and GUI methods Reduce PDF File Size in Linux: Tools and Methods How To Set Up a Private Docker Registry on Ubuntu How To Troubleshoot Terraform: Errors and Fixes How to Use Go Modules Python Multiprocessing Example: Process, Pool & Queue Convert Class Components to Functional Components with React Hooks How To Install and Configure Ansible on Ubuntu LLM Tokenizers Simplified: BPE, SentencePiece, and More How To Monitor System Authentication Logs on Ubuntu How to Use Traceroute and MTR to Diagnose Network Issues How to Deploy Postgres to Kubernetes Cluster Importing Packages in Go: A Complete Guide Create RAID Arrays with mdadm on Ubuntu How To Make an HTTP Server in Go How To Set Up Time Synchronization on Ubuntu How To Use Struct Tags in Go apt-key Deprecation: Add Repositories with GPG on Ubuntu Python struct.pack and struct.unpack for Binary Data Deadlock in Java: Examples, Detection, and Prevention How To Use Find and Locate to Search for Files on Linux Structured Resume Skill Extraction Using Mistral-7B Inference How to Use the Python Main Function How to Set Up NemoClaw on a DigitalOcean Droplet with 1-Click Build an End-to-End RAG Pipeline for LLM Applications From Single to Multi-Agent Systems: Key Infrastructure Needs Back Up Data to Object Storage Using Restic How to Generate Videos with LTX-2.3 on DigitalOcean GPU Droplets How To Install LAMP Stack (Apache, MySQL, PHP) on Ubuntu How to Download Files with cURL How To Use Variadic Functions in Go Generate UUIDs with uuidgen on Linux How To Use EJS to Template Your Node Application How to Install Node.js on Ubuntu (Step-by-Step Guide) MongoDB Indexes: Improve Query Performance with Node.js LLM Tool Calling with DigitalOcean AI Platform and Databases What are Text Diffusion Models? - An Overview Crafting a Game from Scratch with GPT-5.4 Building Long-Term Memory in AI Agents with LangGraph and Mem0 How To Install PHP 7.4 and Set Up a Local Development Environment on Ubuntu 20.04 Build a GraphQL API in Go to Upload Files to Spaces How To Lint and Format Code with ESLint in Visual Studio Code Train YOLO26 for Retail Object Detection on DigitalOcean GPUs How To Work with JSON in MySQL How to Use the JavaScript .map() Method Building a Scalable App with MongoDB Using DigitalOcean's MCP Server How to Create an SSH Key in Linux: Easy Step-by-Step Guide Measure MySQL Query Performance with mysqlslap How To Use *args and **kwargs in Python 3 Nemotron 3 helped me find the perfect dish rack? A2A vs MCP - How These AI Agent Protocols Actually Differ How To Install and Manage Supervisor Docker Container Images with Watchtower on Ubuntu Getting Started with Qwen3.5 Vision-Language Models How To Create a New Sudo-Enabled User on Ubuntu How to Use Ansible to Install and Set Up Docker on Ubuntu How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 How To Convert a String to a List in Python How To Check If a String Contains Another String in Python How to Read a Properties File in Python Python Command Line Arguments: sys.argv, argparse, getopt Mastering Grep command in Linux/Unix: A Beginner's Tutorial Understanding Python Data Types How to Implement a Stack in C With Code Examples Python os.system() vs subprocess: Run System Commands How To Install and Use Docker Compose on Ubuntu How to Add and Delete Users on Ubuntu How To Order Query Results in Laravel Eloquent How To Define and Use Handlers in Ansible Playbooks How To Install and Use SQLite on Ubuntu How To Install and Use Homebrew on macOS How To Manage DateTime with Carbon in Laravel and PHP How To Install Git on Ubuntu How To Install and Secure Redis on Ubuntu How To Build and Install Go Programs on Linux Using ldflags to Set Version Information for Go Applications How To Build a Node.js Application with Docker How To Add JavaScript to HTML How To Reset Your MySQL or MariaDB Root Password How To Add Images in Markdown How To Set Up a Production Elasticsearch Cluster with Ansible How To Set Up a Firewall Using firewalld on CentOS Understanding Systemd Units and Unit Files How To Set Up Replication in MySQL How To Use the .htaccess File
Linux ps Command: 20 Real-World Examples
2026-03-23 · via DigitalOcean Community Tutorials

Introduction

Linux ps commands give you a snapshot of what is running on the system: process IDs (PIDs), parent PIDs (PPIDs), owners, CPU and memory use, and the command line that started each task. Unlike interactive monitors such as top, ps is built for scripts, one-off inspection, and pairing with pipes (see An Introduction to Linux I/O Redirection for how redirection fits into the same toolkit).

This tutorial walks through twenty focused examples, from a plain ps through ps aux, ps -ef, custom columns, trees, threads, and grep. Set up a lab server with Initial Server Setup for Ubuntu if you need a fresh host. The article also adds reference material that competing articles often skip: process state codes, how ps behaves in containers, sorting output, when to use top or pgrep instead, and small shell patterns you can paste into maintenance scripts. For live resource monitoring on a server, pair these ideas with How To Use top, netstat, du, & Other Tools to Monitor Server Resources.

Key takeaways

  • ps reads process data exposed under /proc and prints a static picture at the moment you run it; combine it with watch or a scheduler for repeated checks.
  • ps aux (BSD style) and ps -ef (POSIX / GNU long listing) are the two most common starting points for listing all running processes on Linux.
  • The STAT (or S) column uses single-letter state codes such as R (running) and Z (zombie); knowing them helps you interpret hung or stuck tasks.
  • PID identifies a process; PPID identifies its parent. Tree options and --ppid help you trace service trees and session leaders.
  • Inside Docker or Kubernetes, ps only sees processes in the container’s PID namespace, so process lists look smaller than on the host.
  • For scripting, ps -C name, ps -p, and pgrep are often cleaner than giant ps aux | grep pipelines (and easier to read alongside Bash history and expansion tips).

Understanding columns, process states, and style variants

Common columns you will see

Column Meaning
PID Process ID
PPID Parent process ID
USER / UID Account running the process
%CPU CPU time divided by elapsed time (approximate load)
%MEM Resident set size as a percent of physical memory
VSZ Virtual memory size (KiB)
RSS Resident set size (KiB)
TTY Controlling terminal (? if none)
STAT / S Process state code (see next table)
START / TIME Start time or cumulative CPU time
CMD / COMMAND Command with arguments

Exact columns depend on which options you pass (for example ps aux versus ps -ef).

Process state codes (STAT / S)

These letters describe what the kernel thinks the process is doing. You will mostly see the first character; additional characters mark session leaders, threads, and priority hints.

Code Meaning
R Running or runnable (on a run queue)
S Interruptible sleep (waiting on I/O or an event)
D Uninterruptible sleep (often disk or NFS); can look “stuck”
Z Zombie (exited but not yet reaped by its parent)
T Stopped by job control signal (SIGSTOP, SIGTSTP, or debugger)
t Stopped by debugger during trace
I Idle kernel thread (common on newer kernels in some views)

If you see many D states during storage outages, investigate disk or network filesystems. If you see Z, the parent should call wait(); fixing the parent or restarting the service usually clears them.

BSD style, POSIX style, and GNU ps

Linux ps accepts several historical option styles:

  • BSD style: options without a leading dash, for example ps aux.
    • a shows processes for all users with a terminal; u adds user-oriented columns; x includes processes without a controlling TTY.
  • POSIX / UNIX style: options with a leading dash, for example ps -ef.
    • -e selects every process; -f prints a full-format listing; -F is an even wider variant on GNU ps.

On the same host you can compare:

ps aux | head -n 5
ps -ef | head -n 5

Both list all processes in typical usage, but column names and layout differ. Pick one style for scripts and stay consistent.

Basic ps command examples (20)

The subsections below are the twenty practical examples. Each one shows the command and a sample screenshot from the original walkthrough.

1. ps without arguments

The ps command without arguments lists processes tied to the current shell.

ps

Output ps command

The output consists of four columns:

  • PID: the unique process ID
  • TTY: the type of terminal the user is logged in to
  • TIME: the time in minutes and seconds that the process has been running
  • CMD: the command that launched the process

2. All processes: ps -A or ps -e

To list every process on the machine, use ps -A or ps -e.

To have a glance at all the running processes, execute the command below ps -A Output ps -A command

or ps -e Output ps -e command

3. Processes attached to this terminal: ps -T

To view processes associated with the terminal run ps -T Output ps -T command

4. Processes not tied to a TTY: ps -a

To view all processes except session leaders and those attached to a terminal, run ps -a. A session leader is a process that started its session.

Output ps -a command

5. Classic “everything” combo: ps -ax

To view all current processes (including those without a controlling tty):

ps -ax

Output ps -ax command

-a includes processes owned by others when they have a tty; -x adds processes with no tty.

6. BSD-style user listing: ps au and ps aux

If you wish to display processes in BSD format:

ps au

OR

ps aux

Output ps aux

7. Full listing: ps -ef and ps -eF

To view a full-format listing:

ps -ef

OR

ps -eF

Output ps -ef command

8. Filter by user: ps -u

If you wish to list processes for a specific user, use -u:

ps -u user

For example:

ps -u jamie

Output ps-u username command

9. Threads for one PID: ps -L

If you wish to list threads for a particular process, use -L with a PID:

ps -L 4264

Output ps -L PID command

10. Everything running as root: ps -U root -u root

Sometimes you want every process whose real and effective user is root:

ps -U root -u root

Output ps-processes-owned-by-root

11. Filter by group: ps -fG

If you wish to list processes for a group by name or GID:

ps -fG group_name

Or:

ps -fG groupID

For example:

ps -fG root

Output ps -fG group_name

12. Resolve PID from command name: ps -C

You can search by executable name:

ps -C process_name

For example:

ps -C bash

Output ps -c processname

13. Full format for one PID: ps -fp

Display one process in full format:

ps -fp PID

For example:

ps -fp 1294

Output ps -fp PID command

14. Tree view: ps --forest

Parent and child relationships are easier to see in a forest layout:

ps -f --forest -C bash

Output ps -f --forest -C command

15. Custom columns for a command: ps -o

For example, to show PID, user, and command for every bash process:

ps -o pid,uname,comm -C bash

Output ps -o pid,uname,comm -C command

The first process owned by root is often the main supervisor; workers may show under it.

16. Child processes of a parent PID: ps --ppid

To list children of a known parent PID:

ps --ppid 1294

Output ps --ppid PID command

17. Threads with ps -p … -L

To list every thread row for one PID:

ps -p 1294 -L

Output ps -p pid_no -L

Replace 1294 with the PID you care about.

18. Choose columns once: ps -e -o …

You can print only the fields you need:

ps -e -o pid,uname,pcpu,pmem,comm

Output ps -e -o pid,uname,pcpu,pmem,comm

19. Friendly column headers

Rename columns at print time:

ps -e -o pid=PID,uname=USERNAME,pcpu=CPU_USAGE,pmem=%MEM,comm=COMMAND

Output ps rename columns

20. Elapsed time and grep

Show how long processes have been running:

ps -e -o pid,comm,etime

Output ps -e -o pid,comm,etime

The -o option adds etime, which is handy when you suspect a stuck worker.

Finally, combine ps with grep when you need a quick filter (remember grep also matches its own process unless you exclude it):

ps -ef | grep systemd

Output ps and grep command

Sorting and formatting ps output

GNU ps supports --sort so you can rank processes without leaving the command. Examples:

ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head -n 15
ps -eo pid,comm,%cpu,%mem --sort=-%mem | head -n 15

A leading minus sorts descending. These pairs answer the common question how to sort ps output by CPU or memory usage on Linux hosts.

Combining ps with signals, kill, and services

ps helps you find a PID; kill, killall, or your init system performs the action. Typical pattern:

  1. Run ps -fp PID or ps -C service to confirm the process.
  2. Prefer a graceful stop: for systemd units use sudo systemctl stop unit (see How To Use Systemctl to Manage Systemd Services and Units).
  3. If you must signal directly, kill PID sends SIGTERM by default; use kill -9 PID only when a process ignores normal termination.

This keeps kill process by PID on Linux workflows explicit and avoids guessing IDs.

ps inside containers and Kubernetes pods

Containers use PID namespaces. When you run ps inside a Docker or containerd container, PID 1 is usually your entrypoint, and you only see processes in that namespace, not every host process. That surprises people who expect the full host list.

  • Docker: docker exec -it container ps aux
  • Kubernetes: kubectl exec -it pod -- ps aux

For cgroup-aware views across nodes, operators often rely on kubectl top or metrics servers; ps remains useful for quick debugging inside the pod filesystem.

ps versus top, htop, pgrep, and pstree

Tool What it does best Notes
ps Scriptable snapshot, custom columns, easy to pipe No built-in refresh
top Live CPU and memory, sortable while running Interactive; great for incidents
htop Friendlier top, tree view, search May need install
pgrep / pidof Return PIDs by name Ideal for scripts
pstree ASCII process tree Shows parent/child without ps --forest

When readers search top htop process monitoring tools, point them at top for live dashboards and ps for repeatable listings.

Shell scripting patterns and zombie hunting

Check whether a service binary is running

Using ps -C avoids a fragile grep on the full aux table:

if ps -C nginx -o pid= | grep -q '[0-9]'; then
  echo "nginx is running"
else
  echo "nginx is not running"
fi

pgrep -x nginx is another clean option.

Find zombie processes

Zombies show Z in the state field. Example:

ps -eo pid,ppid,stat,cmd | awk '$3 ~ /Z/ { print }'

Investigate the parent PID in the second column; it should reap child exit statuses.

FAQs

1. What is the ps command used for in Linux?

ps prints information about running processes: PIDs, users, CPU and memory use, command lines, and kernel state codes. It is the standard tool for process status on the Linux command line when you want a point-in-time list instead of a live dashboard.

2. What is the difference between ps aux and ps -ef?

They both list processes for all users in typical use, but they come from different option styles. ps aux is BSD style (a, u, x). ps -ef is POSIX style (-e every process, -f full format). Columns and ordering differ; pick one format for monitoring scripts so parsers stay stable.

3. How do I list all processes in Linux using ps?

Use ps aux, ps -ef, ps -e, or ps -A. For a wide GNU view, ps -eF adds extra columns. These commands answer searches for list all running processes Linux.

4. How do I find the PID of a running process?

Use ps -C name, ps -ef | grep pattern (mind the extra grep line), or pgrep. For a known PID’s details, ps -fp PID shows the full command line.

5. What do the process state codes mean in ps output?

R means runnable, S means sleeping, D means uninterruptible sleep, Z means zombie, and T means stopped. See the table in this guide for quick reference when diagnosing stuck or dead processes.

6. How do I sort ps output by CPU or memory usage?

On GNU ps, add --sort=-%cpu or --sort=-%mem with an -o field list, for example ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head.

7. Can I use ps inside a Docker container?

Yes. ps inside the container only sees that container’s PID namespace, so the list is shorter than on the host. Install procps in minimal images if ps is missing.

8. What is a zombie process and how do I find one with ps?

A zombie is a process that exited but whose parent has not read its exit status. In ps, the state column contains Z. Use ps -eo pid,ppid,stat,cmd | awk '$3 ~ /Z/ { print }' to list them, then fix or restart the parent service.

Conclusion

You now have a full set of Linux ps commands for daily administration: listing processes, interpreting ps aux and ps -ef, working with PID and PPID, formatting columns, sorting, spotting zombies, and understanding container namespaces. Pair this knowledge with interactive monitors from the server monitoring tools tutorial when you need live graphs during incidents.

Next steps

Creative CommonsThis work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.