Site Tools


wiki:debian-processes

Debian Processes

A process is a running instance of a program. Each has a unique process ID (PID), parent process ID (PPID), and runs as a specific user.

Listing Processes

List all processes:

ps aux

Output: USER, PID, CPU%, MEM%, VSZ, RSS, TTY, STAT, START, TIME, COMMAND

Show process tree:

ps -ef
pstree          # tree view

Process Monitor

Real-time monitoring:

top

Commands in top: - space — refresh now - q — quit - k — kill process - M — sort by memory - P — sort by CPU

Modern alternative:

htop

More user-friendly than top.

Killing Processes

Send terminate signal (graceful shutdown):

kill PID

Force kill (no graceful shutdown):

kill -9 PID

Kill by name:

pkill name
pkill -f "pattern"      # match full command

Process States

Show in ps output (STAT column):

  • R — running
  • S — sleeping (waiting for event)
  • D — disk sleep (uninterruptible)
  • Z — zombie (finished, parent hasn't reaped)
  • T — stopped
  • + — foreground group
  • l — multi-threaded
  • s — session leader

Zombie processes hang around until parent collects exit status. Kill the parent to clean up:

kill PPID

Process Hierarchy

Processes form a tree, rooted at PID 1 (systemd or init). Child processes are managed by their parent.

Orphaned processes are re-parented to PID 1. Background processes survive terminal closure if nohup'd:

nohup ./long-job &

Process Info

Detailed process info:

```bash ps -p PID -o pid,ppid,user,cmd cat /proc/PID/status # kernel view lsof -p PID # open files

wiki/debian-processes.md · Last modified: by 127.0.0.1