You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Every running program in Linux is a process. Understanding how to view, manage, and control processes — as well as how to work with system services — is essential for system administration and troubleshooting.
A process is an instance of a running program. Each process has:
| Attribute | Description |
|---|---|
| PID | Process ID — unique numeric identifier |
| PPID | Parent Process ID — the process that started this one |
| UID | User ID — who owns the process |
| State | Running, sleeping, stopped, zombie, etc. |
| Nice value | Process priority (-20 highest to 19 lowest) |
| Memory | Resident and virtual memory usage |
| CPU | CPU time consumed |
ps # show processes in current terminal
ps aux # show all processes (BSD syntax)
ps -ef # show all processes (System V syntax)
ps aux --sort=-%mem # sort by memory usage (descending)
ps aux --sort=-%cpu # sort by CPU usage (descending)
ps -u alice # show processes owned by alice
ps -p 1234 # show info about PID 1234
ps aux | grep nginx # find nginx processes
Understanding ps aux output:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 16968 10240 ? Ss 09:00 0:01 /sbin/init
alice 1234 2.5 1.0 98760 40960 pts/0 S+ 10:30 0:45 python3 app.py
| State | Symbol | Description |
|---|---|---|
| Running | R | Currently executing on CPU |
| Sleeping | S | Waiting for an event (interruptible) |
| Uninterruptible sleep | D | Waiting for I/O (cannot be interrupted) |
| Stopped | T | Stopped by a signal (e.g., Ctrl+Z) |
| Zombie | Z | Finished but parent hasn't read exit status |
top # interactive process monitor
top keyboard shortcuts:
| Key | Action |
|---|---|
| M | Sort by memory |
| P | Sort by CPU |
| k | Kill a process (enter PID) |
| r | Renice a process |
| 1 | Show individual CPU cores |
| q | Quit |
sudo apt install htop # install htop
htop # interactive, colourful process monitor
Tip:
htopprovides a much better experience thantopwith mouse support, colour coding, and an intuitive interface.
./long_task.sh # run in foreground
./long_task.sh & # run in background
Ctrl+Z # suspend (stop) the foreground process
bg # resume suspended process in background
fg # bring background process to foreground
jobs # list background/stopped jobs
fg %2 # bring job number 2 to foreground
Send signals to processes:
kill 1234 # send SIGTERM (graceful shutdown) to PID 1234
kill -9 1234 # send SIGKILL (force kill) — use as last resort
kill -HUP 1234 # send SIGHUP (reload configuration)
killall nginx # kill all processes named nginx
pkill -f "python app.py" # kill processes matching a pattern
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.