Search Authority

The ps Command in Linux: 9 Practical Examples - LinuxSimply

The ps command in Linux is a fundamental tool for viewing and managing processes directly from the terminal. With practical examples, users can quickly monitor resource usage, t...

Mara Ellison
The ps Command in Linux: 9 Practical Examples - LinuxSimply

The ps command in Linux is a fundamental tool for viewing and managing processes directly from the terminal. With practical examples, users can quickly monitor resource usage, troubleshoot issues, and control applications running on the system.

This guide presents 9 practical examples of the ps command, explaining key options, real scenarios, and common workflows for both everyday use and advanced debugging.

Command Description Use Case Typical Output Fields
ps aux Show detailed information for all processes Get a full snapshot of system activity USER, PID, %CPU, %MEM, VSZ, RSS, TTY, STAT, START, TIME, COMMAND
ps -ef Display full-format process listing View process hierarchy with PPID UID, PID, PPID, C, STIME, TTY, TIME, CMD
ps -p PID Show information for a specific process ID Inspect a single process in detail PID, TTY, TIME, CMD
ps -u USER List processes owned by a specific user Audit or limit view to one user’s processes USER, PID, %CPU, MEM, VSZ, RSS, STAT, COMMAND

Process Listing Basics with ps

Display all processes for the current user

Using ps without options shows only processes tied to the current terminal session. This basic view helps identify active tasks without system-wide noise, making it ideal for quick checks.

Show detailed info for all processes

The ps aux command lists every process on the system with resource usage details. It is a go-to command for system monitoring, helping you see CPU and memory consumption at a glance.

Filter and Search Processes

Search by process ID

The ps -p PID option focuses on a single process, providing key details like status, elapsed time, and command used. This targeted approach is helpful for scripts and troubleshooting specific services.

Filter by user

With ps -u USER, you can review only the processes belonging to a specific account. This is useful in multi-user environments to monitor activity, enforce limits, or debug permission-related issues.

Process Control and Signals

Send signals to processes

ps outputs the PID, which you can use with kill to send signals such as SIGTERM or SIGKILL. Controlling processes in this way allows graceful restarts, pauses, or forced terminations when necessary.

  • Start with ps aux for a comprehensive overview of system processes
  • Use ps -p to inspect individual processes by PID quickly
  • Filter output with ps -u to manage multi-user environments
  • Pipe ps results to grep, watch, or sort for more powerful monitoring
  • Leverage PID values from ps when sending signals with kill

FAQ

Reader questions

How do I find the PID of a specific process using ps?

Pipe the output of ps aux to grep with the process name, for example: ps aux | grep nginx. This filters the list so you can quickly locate the PID associated with your target process.

Can ps show the full command line with arguments?

Yes, ps aux or ps -ef both display the complete command line including arguments, helping you understand how a process was started and which options are in use.

How can I monitor process resource usage over time?

Combine ps with tools like watch, for example: watch -n 1 'ps aux --sort=-%cpu | head', to refresh the process list periodically and observe changing CPU and memory usage.

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

ps aux shows CPU and memory usage in percentage format, while ps -ef uses a different column layout and includes parent PIDs. Both reveal full command lines, but the choice depends on your preferred format and sorting needs.

Related Reading

More pages in this topic cluster.

Brigand (Fire Emblem):角色 profile 与战斗指南

在 Fire Emblem 系列中,Brigand 是一种以近战物理为特色的敌我通用职业,通常使用刀剑或斧头,偏向高机动与中等攻击的组合。相较于 Sw...

Read next
Cleo in King's Raid:角色背景、定位与养成指南

Cleo 是 King's Raid 中以机动性与持续输出见长的角色,主要承担副输出或功能型前锋职责。她在队伍中的核心价值体现在灵活切入战场、...

Read next
Oldest Ice Skater: Defying Age on the Ice

The title of oldest ice skater often refers to dieners who have competed or performed well into their eighties and nineties. These athletes combine decades of training with bala...

Read next