Skip to content

ps

16 commands

Reports a snapshot of running processes, with owners, resource usage and full command lines.

  • processes
  • triage

Install ps

sudo apt install procps

Listing6

ps aux

Every process on the system (BSD style): user, PID, CPU and memory share, start time and full command.

ps -ef

Every process (System V style) with parent PIDs — good for seeing what started what.

ps -ef --forest

Draws the process tree, making a suspicious child under a web server easy to spot.

ps -u <user>

Processes owned by one user.

Link
ps -p <pid> -o pid,ppid,user,etime,cmd

Chosen columns for one process, including how long it has been running.

Link
ps -C <name>

Processes by command name.

Link

Sorting and formatting5

ps aux --sort=-%cpu | head

The top CPU consumers.

ps aux --sort=-%mem | head

The top memory consumers.

Link
ps -eo pid,user,lstart,cmd

Exact start time of each process — useful for incident timelines.

Link
ps -eo pid,ppid,cmd --no-headers

Scriptable output without the header line.

Link
ps -eLf

Shows individual threads.

Link

Investigation5

ps aux | grep -v "\]quot;

Hides kernel threads (shown in brackets) to focus on user-space processes.

Link
ls -l /proc/<pid>/exe

Shows the binary a process is really running; “(deleted)” means it was removed from disk after starting — a common malware trick.

Link
cat /proc/<pid>/cmdline | tr "\0" " "

Reads the exact command line, arguments included.

Link
ls -l /proc/<pid>/cwd

Shows the working directory of a process.

Link
pgrep -a <name>

Finds PIDs by name and shows their command lines.

Link