0
0
Linux CLIscripting~5 mins

Why process control manages running programs in Linux CLI - Why It Works

Choose your learning style9 modes available
Introduction
When you run programs on your computer, the system needs to keep track of them. Process control helps manage these running programs so they don't interfere with each other and your computer stays organized.
When you want to see which programs are currently running on your computer
When you need to stop a program that is not responding
When you want to pause a program and resume it later
When you want to start a program in the background so you can keep using the terminal
When you want to check how much memory or CPU a program is using
Commands
This command lists all running programs with details like user, CPU, and memory usage. It helps you see what is currently running on your system.
Terminal
ps aux
Expected OutputExpected
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.1 169084 5404 ? Ss 10:00 0:01 /sbin/init user 2345 0.1 1.2 256000 25000 pts/0 S+ 10:05 0:10 /usr/bin/python3 script.py
a - Show processes for all users
u - Display the process's user/owner
x - Show processes not attached to a terminal
This command stops the program with process ID 2345. Use it when a program is frozen or you want to close it from the command line.
Terminal
kill 2345
Expected OutputExpected
No output (command runs silently)
This command shows a live view of running programs and their resource use. It updates every few seconds so you can watch how programs behave over time.
Terminal
top
Expected OutputExpected
top - 10:10:00 up 1 day, 2:34, 2 users, load average: 0.00, 0.01, 0.05 Tasks: 150 total, 1 running, 149 sleeping, 0 stopped, 0 zombie %Cpu(s): 1.0 us, 0.5 sy, 0.0 ni, 98.0 id, 0.5 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 2048000 total, 500000 free, 800000 used, 748000 buff/cache PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2345 user 20 0 256000 25000 5000 S 0.3 1.2 0:10.00 python3
This command resumes a paused program in the background, so it keeps running but you can still use the terminal for other commands.
Terminal
bg %1
Expected OutputExpected
[1]+ python3 script.py &
This command brings a background program back to the foreground so you can interact with it directly.
Terminal
fg %1
Expected OutputExpected
python3 script.py
Key Concept

If you remember nothing else, remember: process control lets you see, stop, pause, and manage running programs so your computer stays organized and responsive.

Common Mistakes
Trying to kill a program without knowing its correct process ID
You might stop the wrong program or get an error if the ID does not exist
Use 'ps aux' or 'top' to find the exact process ID before using kill
Using kill without specifying the signal and expecting the program to stop immediately
Some programs ignore the default signal and keep running
Use 'kill -9 PID' to force stop if the normal kill does not work
Not using bg or fg correctly to manage background and foreground jobs
You may lose control of the program or block the terminal
Use 'Ctrl+Z' to pause, then 'bg' to resume in background or 'fg' to bring back to foreground
Summary
Use 'ps aux' to list all running programs and their details.
Use 'kill' with the correct process ID to stop a program.
Use 'top' to monitor running programs and their resource use live.
Use 'bg' and 'fg' to manage programs running in the background or foreground.