Linux Process Management – Beginner
Guide
Introduction
A process is any running program or task on a Linux system. This guide will teach you how to
view, monitor, control, and manage processes using built-in commands.
Viewing Processes
1. Ps
Shows only processes of the current shell.
2. ps aux
a: All users
u: Show user info
x: Include background processes
Example:
i. ps aux | less - View all processes, paginated.
Viewing Processes by User
1. Current user:
ps -u $USER
2. Specific user:
ps -u username
Identify High Resource Usage
1. Memory:
ps aux --sort=-%mem | head
2. CPU:
ps aux --sort=-%cpu | head
Real-Time Monitoring
1. top
Real-time view of processes.
Press P: sort by CPU
Press M: sort by Memory
Killing a Process
1. Find PID:
ps aux | grep programname
2. Kill normally:
kill <PID>
3. Force kill:
kill -9 <PID>
Foreground & Background Processes
1. Run in background:
sleep 100 &
2. List background jobs:
Jobs
3. Bring to foreground:
fg %1
4. Suspend foreground:
Ctrl + Z
5. Resume in background:
bg <process_name>
Monitor Specific Process
1. watch -n 1 ps -p <PID> -o pid,ppid,cmd,%mem,%cpu
Repeats every second.
Additional Useful Commands
1. Pidof
pidof firefox
Get PID of a process.
2. Pgrep
pgrep apache2
Find process by name.
3. Nice
nice -n 10 somecommand
Start a process with a specific priority.
4. Renice
renice -n 5 -p <PID>
Change priority of a running process.
Practice Tasks
1. List all processes using ps aux
2. View your user’s processes: ps -u $USER
3. Sort processes by memory usage
4. Use top and htop to analyze performance
5. Run a process in the background and use jobs, fg, and bg
6. Kill a dummy process like sleep
7. Monitor a process with watch
8. Find a process PID using pgrep or pidof