Monitor Linux Processes with ps, top and htop

Monitor Linux processes with ps, top and htop: key options, column meanings, process states, kill and renice, and a five-minute routine for slow servers.

Aug 2, 2025 - 16:45
Nov 9, 2026 - 05:13
 0  98
Monitor Linux Processes with ps, top and htop

To monitor active processes in Linux, use ps for a one-time snapshot you can filter and script, top for a live view that refreshes every few seconds, and htop for an interactive, colour-coded view with tree mode and mouse support. All three read the same data from /proc, so they differ in presentation and interaction rather than accuracy.

This guide is part of our Linux and RHEL learning track, which starts with setting up RHEL 10 for the first time. It walks through the options you will actually use in each tool, how to read the columns, and a short troubleshooting routine for a busy server. Every command was checked against the procps-ng and htop manual pages.

Key takeaways

  • ps prints a static list. Combine it with -eo and --sort to build exactly the report you need, which makes it the right tool for scripts and cron jobs.
  • top ships with almost every distribution through the procps-ng package. Single keys inside it sort, filter, renice and kill processes.
  • htop is usually an extra package (on RHEL it comes from EPEL). It adds scrolling, tree view, search and function-key menus.
  • Load average counts tasks that are running or waiting, including tasks stuck in uninterruptible I/O (state D), so a high load does not always mean CPU is the bottleneck.
  • Always try SIGTERM (15) before SIGKILL (9), and prefer systemctl for processes that belong to a service.

ps vs top vs htop at a glance

Featurepstophtop
OutputOne snapshot, then exitsLive, refreshes (default 3 seconds)Live, refreshes, scrollable
Installed by defaultYes (procps-ng)Yes (procps-ng)Usually not; install the htop package
Best forScripts, filtering, exact columnsQuick checks on any serverInteractive investigation
Kill or reniceNo (use kill, renice)Yes, keys k and rYes, F9 and F7/F8
Process treeps -ef --forest or ps axjfKey V (forest view)F5
Batch outputNativetop -b -n 1Not designed for it

What a process is, in the terms these tools use

Every running program is a process with a process ID (PID) and a parent process ID (PPID). On a systemd distribution, PID 1 is systemd, and everything else descends from it. The kernel exposes each process as a directory under /proc/<PID>, and ps, top and htop all read those files. If you open /proc/1/status you will see the same state, memory and thread figures the tools display.

Each process has a state code. You will see these in the STAT or S column:

CodeMeaningWhat to think when you see many
RRunning or runnableCPU demand is high
SInterruptible sleep (waiting for an event)Normal; most processes sit here
DUninterruptible sleep, usually disk or network I/OStorage or NFS may be slow
ZZombie: exited, but the parent has not collected its statusA parent process is not reaping children
TStopped by a signal or a debuggerSomeone pressed Ctrl+Z or attached a tracer
IIdle kernel threadNormal

Using ps for snapshots

ps accepts two option styles. BSD style has no dash (ps aux) and UNIX style uses a dash (ps -ef). Both list every process; they just choose different default columns.

# Every process, BSD style: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
ps aux

# Every process, UNIX style: UID PID PPID C STIME TTY TIME CMD
ps -ef

# Processes owned by one user
ps -u nginx

# A single PID with chosen columns
ps -o pid,ppid,user,stat,etime,cmd -p 1234

Build your own report with -eo and --sort

The most useful ps habit is choosing columns and sorting. This command lists the ten processes using the most CPU:

ps -eo pid,ppid,user,%cpu,%mem,stat,etime,comm --sort=-%cpu | head -n 11

Swap --sort=-%cpu for --sort=-%mem or --sort=-rss to rank by memory. The minus sign means descending. Note that ps %CPU is the average over the life of the process, not the last few seconds. For current CPU use, look at top.

Find processes by name

Avoid ps aux | grep name, because it also matches the grep command itself. pgrep is cleaner:

# PIDs and names of matching processes
pgrep -l sshd

# Match against the full command line, show it
pgrep -af "java -jar"

# Count zombie processes
ps -eo stat | grep -c '^Z'

See the process tree

ps -ef --forest
# or the pstree command from the psmisc package
pstree -p

A tree shows which parent spawned a runaway child. With zombies, the fix is almost always the parent: restart or fix the parent so it reaps its children. You cannot kill a zombie directly because it has already exited.

Using top for a live view

Run top and the screen splits into a summary area and a task list. The first line shows uptime, logged-in users and the load average for the last 1, 5 and 15 minutes. The CPU line breaks time into categories:

FieldMeaning
usUser space processes
syKernel
niNiced (lower priority) user processes
idIdle
waWaiting for I/O
hi / siHardware and software interrupts
stStolen by the hypervisor (virtual machines)

A high wa points at storage. A high st on a cloud VM means the host is short of CPU, and resizing or moving the instance may help more than tuning the application.

Keys worth memorising

KeyAction
PSort by CPU
MSort by memory
TSort by cumulative CPU time
1Toggle per-CPU lines
cShow full command line
uFilter by user
oAdd a filter such as COMMAND=java
HShow threads instead of processes
VForest (tree) view
kSend a signal to a PID
rRenice a PID
dChange refresh delay
WSave current layout to the config file
qQuit

Command-line options

# Watch specific PIDs only
top -p 1234,5678

# Only one user's processes
top -u postgres

# Refresh every second
top -d 1

# Batch mode: one iteration, text output for logs or scripts
top -b -n 1 | head -n 20

Batch mode is handy in an incident: run top -b -n 3 -d 5 > /tmp/top.txt and attach the file to the ticket so others can see what the machine looked like.

Using htop for interactive work

htop is a separate project. Install it with your package manager:

# Ubuntu / Debian
sudo apt install htop

# RHEL, Rocky, AlmaLinux (htop is in EPEL)
sudo dnf install epel-release   # on RHEL, follow the EPEL instructions for your version
sudo dnf install htop

On RHEL itself, enabling EPEL needs the CodeReady Builder repository and the EPEL release package for your major version. Our guide on configuring RHEL 10 repositories covers that step.

Function keys

KeyAction
F1Help
F2Setup: meters, columns, colours
F3Search by name (jumps to matches)
F4Filter (hides non-matches)
F5Tree view
F6Choose sort column
F7 / F8Raise or lower priority (nice)
F9Send a signal
SpaceTag a process (act on several at once)
F10Quit

The meters at the top show each CPU core, memory and swap as coloured bars. In the memory bar, green is memory used by processes, while blue and yellow portions are buffers and cache that the kernel can reclaim. That is why a server can look "full" in a naive reading and still be healthy.

Reading memory columns correctly

ColumnMeaning
VSZ / VIRTVirtual address space reserved. Often large and rarely a concern by itself.
RSS / RESResident memory actually in RAM, including shared pages.
SHRShared memory (libraries, shared segments).
%MEMRSS as a share of physical RAM.

Because shared pages count toward each process's RSS, adding the RSS of every process overstates real use. Use free -h and the available column to judge whether the box is short of memory.

Controlling processes after you find them

Signals

# Ask politely (SIGTERM, 15); the process can clean up
kill 1234

# Reload configuration for daemons that support it (SIGHUP, 1)
kill -HUP 1234

# Force stop (SIGKILL, 9); no cleanup, last resort
kill -9 1234

# By name
pkill -f "python worker.py"

If the process belongs to a systemd service, use systemctl restart name instead, otherwise systemd may simply start it again. Our post on managing services and processes in RHEL 10 covers that workflow.

Priority with nice and renice

Nice values run from -20 (highest priority) to 19 (lowest). Regular users can only lower priority; root can raise it.

# Start a backup at low priority
nice -n 10 tar czf /backup/home.tgz /home

# Lower the priority of a running PID
renice -n 15 -p 1234

A five-minute routine for a slow server

  1. Run uptime and compare the load average with the CPU count from nproc. A load well above the core count for 5 and 15 minutes means sustained pressure.
  2. Open top, press 1, and read us, sy, wa and st. This tells you whether the pressure is CPU, kernel, I/O or the hypervisor.
  3. Press P, then M, to find the top consumers. Note their PIDs and commands (press c for full commands).
  4. If wa is high, look for processes in state D: ps -eo pid,stat,comm | awk '$2 ~ /D/'. Then check disks with iostat -x 1 from the sysstat package.
  5. Check memory with free -h and look for OOM killer messages with journalctl -k | grep -i oom.
  6. Save evidence with top -b -n 1 and ps aux --sort=-%cpu | head before you restart anything.

For deeper tools such as vmstat, iostat, sar and perf, see our guide to the best tools for troubleshooting Linux performance.

Automating checks with ps

Because ps output is stable, it is easy to use in a small script. This example warns when any process uses more than 80 percent of a CPU on average:

#!/usr/bin/env bash
set -euo pipefail
threshold=80
ps -eo pid,%cpu,comm --no-headers | while read -r pid cpu comm; do
  if awk -v c="$cpu" -v t="$threshold" 'BEGIN{exit !(c>t)}'; then
    echo "$(date -Is) high CPU: pid=$pid cpu=$cpu cmd=$comm"
  fi
done

A script like this is fine for a lab or a single server. For fleets, run an agent such as Prometheus node_exporter and alert on metrics rather than parsing ps on every host. Text tools like awk are covered in our grep, awk and sed guide.

Containers and cgroups

Processes inside containers are still ordinary Linux processes, so they show up in ps and top on the host. To see resource use grouped by systemd unit or container cgroup, run systemd-cgtop. For a single container, podman top <container> or docker top <container> lists only its processes.

Frequently asked questions

What is the difference between ps, top and htop?

ps prints a one-time snapshot and exits, which suits scripts. top shows a live, refreshing list and is installed almost everywhere. htop is an interactive alternative to top with scrolling, colour meters, tree view and function-key menus, but it usually needs to be installed.

How do I see the processes using the most CPU?

Run ps -eo pid,user,%cpu,comm --sort=-%cpu | head for a snapshot, or open top and press P. Remember that ps shows average CPU over the life of the process, while top shows recent use.

Is htop installed by default on RHEL?

No. On RHEL and its rebuilds, htop comes from the EPEL repository, so you enable EPEL first and then run dnf install htop. On Ubuntu it is in the standard repositories.

What does a high load average mean?

It means many tasks were running or waiting. Linux counts tasks in uninterruptible I/O wait as well as runnable tasks, so compare load with your CPU count and check the wa value in top before blaming CPU.

How do I remove zombie processes?

A zombie has already exited, so killing it does nothing. Find its parent with ps -o ppid= -p <PID> and restart or fix that parent so it collects the exit status.

Should I use kill -9?

Only as a last resort. Send SIGTERM first so the process can close files and connections. If it belongs to a systemd service, use systemctl to stop or restart it.

How do I save top output to a file?

Use batch mode: top -b -n 1 > top.txt for one snapshot, or add -n 5 -d 2 to capture five snapshots two seconds apart.

Learn Linux administration hands-on

Process monitoring is a core skill in our Linux administration training, offered as classroom sessions in Kharadi, Pune and live online across India. For more command practice, see 20 Linux commands for DevOps engineers.

References

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.