Process Management
Understanding how Linux manages processes is critical for both system administration and security analysis. You will learn to monitor running processes, manage foreground and background jobs, send signals, and identify suspicious processes that may indicate a compromise. Process analysis is a key skill in incident response and malware analysis.
Learning Objectives — Deep Dive
Each objective below is broken down into plain English so you know exactly what you are learning, why it matters, and what you will be able to do when you are done. Mark each one complete as you work through the lesson.
List all running processes
Run 'ps aux' to list all running processes with their user, PID, CPU usage, memory usage, and command line. The output can be long — pipe it through 'less' with 'ps aux | less' to scroll through it, or through 'sort -k3 -rn | head -20' to see the top 20 CPU-consuming processes. In a post-exploitation scenario, the process list reveals what software is running, which users are active, and may expose credentials passed as command-line arguments (a common misconfiguration). Run 'ps aux --forest' to see the parent-child process hierarchy.
ps aux | sort -k3 -rn | head -20Find processes by name
Run 'pgrep -la apache' to find all processes whose name contains 'apache', showing both the PID and the full command line. The 'pgrep' command is more precise than 'ps aux | grep apache' because it does not include the grep process itself in the results. Use 'pgrep -u root' to list all processes running as root — any of these that have exploitable vulnerabilities can be used for privilege escalation. Run 'lsof -p <pid>' to see all files and network connections open by a specific process.
pgrep -la apacheCheck cron jobs
Run 'crontab -l' to list cron jobs for the current user, and 'sudo crontab -l' to list root's cron jobs if you have sudo access. Also check system-wide cron jobs in '/etc/crontab', '/etc/cron.d/', '/etc/cron.hourly/', '/etc/cron.daily/', '/etc/cron.weekly/', and '/etc/cron.monthly/'. Any cron job that runs a script or binary that you can write to is a privilege escalation vector — if root runs '/opt/backup.sh' every minute and you can write to that file, you can inject commands that execute as root. Run 'cat /etc/crontab' and examine every entry carefully.
crontab -l && cat /etc/crontab && ls /etc/cron.*/Kill a process
Run 'kill <pid>' to send the default SIGTERM signal to a process, asking it to terminate gracefully. If the process does not respond to SIGTERM, use 'kill -9 <pid>' to send SIGKILL, which forces immediate termination without cleanup. Use 'killall apache2' to kill all processes with a given name, or 'pkill -u username' to kill all processes owned by a specific user. In a penetration test, you may need to kill a process to free a port, restart a service after modifying its configuration, or terminate a monitoring agent that is logging your activity.
kill -9 <pid>