Five exercises covering process inspection, CPU priority manipulation, signal sending, job control, and security-focused process hunting — the tools you use every time something goes wrong on a server.
ps aux. Identify the column headers: USER, PID, %CPU, %MEM, VSZ, RSS, STAT, START, TIME, COMMAND.ps aux --sort=-%cpu | head -15ps aux --sort=-%mem | head -15pstree -p | head -30 or ps --forest -eo pid,ppid,comm | head -30ps aux | wc -l (subtract 1 for the header)top -bn1 | head -20 (useful for scripts)nice (run with no arguments shows the default)nice -n 15 sleep 300 &ps -p $! -o pid,comm,nice (where $! is the last background PID)ps -eo pid,comm,nice | sort -k3 -rn | head -20renice -n 5 -p $SLEEP_PIDps -p $SLEEP_PID -o pid,comm,nicekill $SLEEP_PIDnice -n -5 sleep 10 & — observe the permission errorsleep 9999 & TESTPID=$!kill -lkill -15 $TESTPID — verify it terminated: ps -p $TESTPID 2>/dev/null || echo "Process ended"sleep 9999 & TESTPID2=$!kill -19 $TESTPID2 — verify state is T: ps -p $TESTPID2 -o pid,statkill -18 $TESTPID2 — state returns to Skill -9 $TESTPID2sleep 1000 & sleep 1000 & pkill -f "sleep 1000"ping localhost — it blocks the terminaljobs — note the job number in bracketsbg %1 — it continues running, terminal is freefg %1 — then Ctrl+C to terminatesleep 500 & sleep 600 & sleep 700 &jobs -l (with PIDs)kill %1 %2 %3 2>/dev/null; jobsnohup sleep 9999 > ~/nohup-test.log 2>&1 & — this survives terminal closureps aux | grep "^root" — know what should and should not run as rootps aux | grep -E "\.\.|\.\//|/tmp|/dev/shm" 2>/dev/nullecho "ps count: $(ps aux | wc -l)" && echo "/proc count: $(ls /proc | grep -E '^[0-9]+$' | wc -l)"ss -tlnp or netstat -tlnp 2>/dev/nulllsof -p $$ | head -20 (using your own shell's PID)ls -la /proc/*/exe 2>/dev/null | grep tmpps aux --sort=-%cpu | awk '$3 > 0.5 {print}' > ~/high-cpu-procs.txtps auxf > ~/snapshot-$(date +%Y%m%d-%H%M%S).txt. Preserve it before any remediation. Rootkits specifically target ps and ls to hide their presence — if /proc shows more processes than ps, you have a rootkit. Use the raw /proc filesystem as your ground truth. The lsof tool (list open files) is invaluable: malware must have files open (executable, config, socket) and lsof reveals them even when the original file has been deleted (the inode remains open).