Lab 14: Processes — ps and Signals

Objective

Monitor Linux processes: ps, top, background jobs, signals, /proc filesystem. Understanding processes is fundamental to system administration, performance tuning, and incident response.

Time: 30 minutes | Level: Foundations | Docker: docker run -it --rm ubuntu:22.04 bash


Step 1: ps — Process Snapshot

ps aux | head -5

📸 Verified Output:

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0   4364  3360 ?        Ss   01:08   0:00 bash
root           7  0.0  0.0   7064  3080 ?        R    01:08   0:00 ps aux
root           8  0.0  0.0   2804  1568 ?        S    01:08   0:00 head -5

Column meanings:

  • PID: Process ID — unique identifier for each process

  • %CPU / %MEM: Resource usage

  • VSZ: Virtual memory size (KB)

  • RSS: Resident set size — actual RAM used (KB)

  • STAT: Process state: S=sleeping, R=running, Z=zombie, s=session leader

  • COMMAND: The command that started the process


Step 2: ps -ef Format (Full Process Tree)

📸 Verified Output:

💡 PPID = Parent Process ID. Every process has a parent except PID 1 (init/systemd). A process tree shows you how programs spawn child processes — critical for understanding attacks where malware spawns shells.


Step 3: Background Jobs

📸 Verified Output:

📸 Verified Output:

💡 & runs a command in the background. jobs lists background jobs for your shell session. fg %1 brings job #1 to foreground. bg %1 resumes a stopped job in background.


Step 4: Killing Processes with Signals

📸 Verified Output:

📸 Verified Output:


Step 5: /proc — Process Information

📸 Verified Output:

📸 Verified Output:

💡 Each process has its own /proc/PID/ directory. Key files: cmdline (full command), environ (environment variables), fd/ (open file descriptors), maps (memory maps). Malware analysts use these to examine suspicious processes.


Step 6: CPU and Memory Info from /proc

📸 Verified Output:

📸 Verified Output:


Step 7: nice — Process Priority

📸 Verified Output:

💡 nice value ranges from -20 (highest priority) to 19 (lowest priority). CPU-intensive batch jobs should run at nice 10-19 so they don't starve interactive processes. Only root can set negative nice values.


Step 8: Capstone — Process Security Audit

📸 Verified Output:


Summary

Command
Purpose

ps aux

All processes (BSD style)

ps -ef

All processes (UNIX style)

ps -eo pid,ppid,cmd

Custom column output

kill PID

Send SIGTERM to process

kill -9 PID

Force kill (SIGKILL)

kill %N

Kill background job N

jobs

List background jobs

fg %N

Bring job to foreground

bg %N

Resume job in background

nice -n N cmd

Run with priority N

/proc/PID/

Per-process info directory

Last updated