Bird
Raised Fist0
Linux CLIscripting~5 mins

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

Choose your learning style10 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.

Practice

(1/5)
1. What is the main purpose of process control in Linux?
easy
A. To manage running programs by starting, stopping, or pausing them
B. To install new software packages
C. To change the screen resolution
D. To create new user accounts

Solution

  1. Step 1: Understand process control basics

    Process control is about managing programs that are currently running on the system.
  2. Step 2: Identify the correct purpose

    Starting, stopping, and pausing programs are key actions in process control.
  3. Final Answer:

    To manage running programs by starting, stopping, or pausing them -> Option A
  4. Quick Check:

    Process control = Manage running programs [OK]
Hint: Process control means managing running programs [OK]
Common Mistakes:
  • Confusing process control with software installation
  • Thinking it manages hardware settings
  • Mixing it up with user account management
2. Which command is used to pause a running process in Linux?
easy
A. kill -9 <pid>
B. kill -STOP <pid>
C. kill -CONT <pid>
D. kill -TERM <pid>

Solution

  1. Step 1: Recall kill command signals

    The kill command sends signals to processes; -STOP pauses, -CONT resumes.
  2. Step 2: Identify pause signal

    Signal -STOP pauses the process without terminating it.
  3. Final Answer:

    kill -STOP <pid> -> Option B
  4. Quick Check:

    Pause process = kill -STOP [OK]
Hint: Use kill -STOP to pause a process [OK]
Common Mistakes:
  • Using kill -9 which forcefully kills the process
  • Confusing -CONT (resume) with pause
  • Using kill -TERM which terminates the process
3. What will be the output of the command sequence below?
sleep 100 &
jobs
kill -STOP %1
jobs
medium
A. Shows the job stopped both times
B. Shows no jobs running
C. Shows the job running, then shows it stopped
D. Shows an error because kill -STOP is invalid

Solution

  1. Step 1: Understand the commands

    sleep 100 & runs sleep in background; jobs lists jobs; kill -STOP %1 pauses job 1.
  2. Step 2: Predict jobs output

    First jobs shows sleep running; after kill -STOP, jobs shows it stopped.
  3. Final Answer:

    Shows the job running, then shows it stopped -> Option C
  4. Quick Check:

    jobs before and after kill -STOP = running then stopped [OK]
Hint: jobs shows status; kill -STOP pauses job [OK]
Common Mistakes:
  • Thinking kill -STOP kills the job
  • Expecting no jobs after sleep &
  • Believing kill -STOP is invalid
4. You run kill -STOP 1234 but the process does not pause. What is the most likely reason?
medium
A. You need to run the command as root
B. You used the wrong signal; should be kill -9
C. The process is already stopped
D. The process ID 1234 does not exist

Solution

  1. Step 1: Check process existence

    If the process ID does not exist, kill commands have no effect.
  2. Step 2: Consider other reasons

    Wrong signal or permissions cause errors, but no pause means no such process.
  3. Final Answer:

    The process ID 1234 does not exist -> Option D
  4. Quick Check:

    Nonexistent PID = no pause [OK]
Hint: Check if PID exists before sending signals [OK]
Common Mistakes:
  • Assuming kill -9 pauses process
  • Ignoring process existence
  • Thinking root is always required
5. You want to temporarily pause a script running in the background, then resume it later. Which sequence of commands correctly achieves this?
hard
A. kill -STOP <pid> to pause, then kill -CONT <pid> to resume
B. kill -TERM <pid> to pause, then kill -STOP <pid> to resume
C. kill -9 <pid> to pause, then restart the script manually
D. kill -CONT <pid> to pause, then kill -STOP <pid> to resume

Solution

  1. Step 1: Identify pause and resume signals

    kill -STOP pauses a process; kill -CONT resumes it.
  2. Step 2: Verify command sequence

    Pause with kill -STOP, then resume with kill -CONT is correct.
  3. Final Answer:

    kill -STOP <pid> to pause, then kill -CONT <pid> to resume -> Option A
  4. Quick Check:

    Pause = kill -STOP, Resume = kill -CONT [OK]
Hint: Pause with STOP, resume with CONT signals [OK]
Common Mistakes:
  • Using kill -9 which kills process
  • Mixing up STOP and CONT signals
  • Trying to resume with STOP signal
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard