Managing Processes (ps, top, kill)
Learn how to list, monitor, and terminate running processes on your system, understanding process IDs and states.
Managing Processes (ps, top, kill) is a free DevOps Bootcamp lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What are Processes?
In Linux, a process is an instance of a running program. Every command you execute, every application you open, runs as one or more processes.
- Processes are managed by the operating system.
- Understanding them is key for monitoring system health and troubleshooting.
Listing Processes with `ps`
The ps command (process status) is used to display information about currently running processes.
By default, it shows processes associated with your current terminal session.
Detailed Process Info (`ps aux`)
To see all processes running on the system, including those started by other users or system services, we use options like aux or -ef.
ps aux: Shows all processes, including those not attached to a terminal.ps -ef: Shows all processes in a full listing format.
Try running ps aux and piping it to head to see the first few lines:
ps aux | head -n 5Understanding `ps` Output
The output of ps aux provides several key columns:
- USER: The user who owns the process.
- PID: Unique Process ID.
- %CPU: CPU usage percentage.
- %MEM: Memory usage percentage.
- COMMAND: The command that started the process.
The PID is especially important for managing processes.
Real-time Monitoring with `top`
While ps gives a snapshot, the top command provides a dynamic, real-time view of running processes.
It continuously updates, showing processes that are consuming the most resources.
Interpreting `top` Metrics
When you run top, you'll see a summary at the top and a process list below.
- Load Average: Average system load over 1, 5, and 15 minutes.
- Tasks: Total, running, sleeping, stopped, zombie processes.
- %Cpu(s): CPU utilization.
- Mem: Total, free, used, buffered memory.
- Process List: Similar columns to
ps, but constantly sorted (default by CPU).
Finding Specific Processes
You can combine ps with grep to filter for specific processes, like finding all processes related to 'bash'.
The grep -v grep part helps exclude the grep command itself from the results.
ps aux | grep -i "bash" | grep -v "grep"Terminating Processes with `kill`
Sometimes a process might hang or consume too many resources. The kill command allows you to send signals to processes, typically to terminate them.
You need the PID of the process you want to kill.
Understanding `kill` Signals
When you use kill, you're sending a "signal" to a process. The default signal is SIGTERM (15), which asks the process to gracefully shut down.
kill PID: Sends SIGTERM.kill -9 PID: Sends SIGKILL. This is a forceful termination that the process cannot ignore. Use it carefully!
You can list all available signals with kill -l:
kill -lPractical `kill` Example
Let's practice terminating a simple background process. We'll start a sleep command in the background, find its PID, and then you can use kill to stop it.
Run the code below. After it runs, you'll see the PID of the sleep process. Then, in your terminal, manually type kill <PID> (replace <PID> with the actual number) to stop it.
# Step 1: Start a dummy process in the background
sleep 300 &
echo "Sleep process started. Now finding its PID..."
# Step 2: Find its Process ID (PID)
# Look for the 'sleep' process in the output
ps aux | grep -i "sleep" | grep -v "grep"
# Step 3: To kill it, manually type 'kill <PID>'
# Example: kill 12345Quick Check: Process Management
You've learned about listing, monitoring, and terminating processes. Let's test your understanding.
Recap: Managing Processes
Great job! In this lesson, you mastered essential Linux commands for process management:
ps: To list processes and get a snapshot of their status.top: For real-time, dynamic monitoring of system processes and resource usage.kill: To send signals to processes, primarily for terminating them gracefully (SIGTERM) or forcefully (SIGKILL).
These tools are crucial for system administration and troubleshooting.
Frequently asked questions
Is the “Managing Processes (ps, top, kill)” lesson free?
Yes — the full text of “Managing Processes (ps, top, kill)” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.
What will I learn in “Managing Processes (ps, top, kill)”?
Learn how to list, monitor, and terminate running processes on your system, understanding process IDs and states. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Managing Processes (ps, top, kill)” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Managing Processes (ps, top, kill)
- Input/Output Redirection (>, >>, <)
- Piping Commands (|)
- Background Jobs & Job Control