Linux Processes Explained: ps, top, kill, and Process Management for Security

Every program running on a Linux system is a process. Understanding how Linux creates, manages, monitors, and terminates processes is foundational for system administrators, DevOps engineers, and ethical hackers who need to enumerate, control, and analyze what is running on any Linux system.
When you open a terminal, run a script, or start a web server, Linux creates a process – an instance of a running program with its own isolated memory space, file descriptors, and execution context. Every process on a Linux system is assigned a unique PID (Process ID) – a numeric identifier the kernel uses to track and control it. The very first process started at boot is systemd (or init), which always holds PID 1. Every other process on the system is a descendant of PID 1, forming a parent-child hierarchy called the process tree.

Linux process states

Every Linux process exists in one of several states at any given moment. Understanding these states is critical for both troubleshooting system performance and enumerating suspicious activity on a target during a security assessment.

Running
 
ActiveCurrently executing on the CPU or waiting in the run queue. High CPU processes stay in R state continuously. 
Sleeping
 
InterruptibleWaiting for an event such as user input or I/O completion. Can be woken by a signal – the most common state for idle processes. 
Disk wait
 
UninterruptibleWaiting for disk I/O – cannot be interrupted by signals. A process stuck in D state often indicates storage or NFS issues. 
Stopped
 
PausedPaused by a signal (SIGSTOP or Ctrl+Z). Will not execute until resumed with SIGCONT. Common in job control and debugging. 
Zombie
 
DefunctFinished executing but not yet reaped by its parent. Holds no resources but occupies a PID slot. Large numbers indicate a buggy parent process. 
Running
 Active: Currently
executing on the CPU or waiting in the run queue. High CPU processes stay in the R state continuously. 

Every process inherits its parent’s environment, file descriptors, and user context via fork(). When a child process finishes, it enters Z (zombie) state until the parent calls wait() to collect its exit code. A runaway zombie count means a parent is not cleaning up – a common bug in poorly written daemons.

Essential process management commands

Process management commands

ps auxList all running processes with user, PID, CPU/memory usage, state, and command – the most used process snapshot command
ps aux | grep apache2Filter process list to find a specific running service – essential for verifying what is actually running on a target
topReal-time interactive process monitor – shows live CPU, memory, and process state. Press k to kill, q to quit
htopEnhanced interactive process viewer with color coding, tree view, and mouse support – install with apt install htop
pgrep sshdReturn the PID of all processes matching the name – faster than grep-ing ps output
pstreeDisplay processes as a tree rooted at PID 1 – shows parent-child relationships at a glance
lsof -p 1042List all files and network connections opened by a specific PID – critical for malware analysis and forensics
nice -n 10 script.shStart a process with lower scheduling priority (niceness 10) –  prevents CPU-intensive tasks from starving other processes

Signals – controlling processes

Linux communicates with running processes through signals — numbered notifications sent by the kernel, the user, or other processes. The kill command sends signals by PID, and p kill sends them by name.

Signal 15 — default
kill -15 (SIGTERM)
 
 
Graceful termination request. The process can catch this signal, save state, and clean up before exiting. Always try this first.
Signal 9 — force
kill -9 (SIGKILL)
 
 
Immediate, uncatchable termination. The kernel kills the process instantly — no cleanup possible. Use only when SIGTERM fails. 
Signal 1 — reload
kill -1 (SIGHUP)
 
 
Originally “hangup” — now widely used to tell daemons to reload their configuration without restarting. Safe for production services. 
Signal 19 — pause
kill -19 (SIGSTOP)
 
 
Pause a process – moves it to T (stopped) state. Resume with kill -18 (SIGCONT). Also triggered by Ctrl+Z in the terminal. 

In penetration testing, ps aux and lsof -p [PID] are used immediately after gaining shell access to enumerate what is running – revealing web servers, databases, backup agents, and monitoring tools that represent additional attack paths or data sources. A process running as root that is listening on a network port is always a high-value target for further exploitation.

Malware on Linux systems frequently disguises itself as a legitimate process name – a reverse shell might appear as bash, python3, or kworker in the process list. Always cross-reference suspicious processes using ls -la /proc/[PID]/exe to verify the actual binary being executed.

Scroll to Top