Bird
Raised Fist0
Linux CLIscripting~10 mins

Why process control manages running programs in Linux CLI - Visual Breakdown

Choose your learning style10 modes available
Concept Flow - Why process control manages running programs
User starts a program
↓
Shell creates a process
↓
Process runs
↓
Process control manages
↓
Pause
↓
Process ends
This flow shows how process control starts, manages, and ends running programs.
Execution Sample
Linux CLI
sleep 10 &
ps
kill %1
ps
Starts a background sleep process, lists processes, kills the sleep, then lists processes again.
Execution Table
StepCommandActionProcess StateOutput
1sleep 10 &Start sleep in backgroundRunning (background)Process started with job ID 1
2psList processesSleep process runningShows sleep process in list
3kill %1Send terminate signal to job 1TerminatingJob 1 terminated
4psList processesSleep process endedSleep process no longer listed
💡 Sleep process ends after kill command, no longer running.
Variable Tracker
VariableStartAfter Step 1After Step 3Final
sleep_processNot runningRunning (background)TerminatedEnded
Key Moments - 3 Insights
Why does the sleep command run in the background after adding '&'?
Adding '&' tells the shell to start the process in the background, so the shell prompt returns immediately (see execution_table step 1).
What does 'kill %1' do exactly?
'kill %1' sends a termination signal to the background job with ID 1, stopping the sleep process (see execution_table step 3).
Why does the sleep process disappear from 'ps' after kill?
Because the process was terminated and ended, so it no longer appears in the process list (see execution_table step 4).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the state of the sleep process after step 1?
ATerminated
BRunning in background
CPaused
DNot started
💡 Hint
Check the 'Process State' column at step 1 in the execution_table.
At which step does the sleep process stop running?
AStep 4
BStep 2
CStep 3
DStep 1
💡 Hint
Look at the 'Process State' and 'Output' columns in steps 3 and 4.
If we remove '&' from the sleep command, what changes in the execution?
ASleep process is terminated immediately
BSleep runs in background as before
CSleep runs in foreground, shell waits until it ends
DShell crashes
💡 Hint
Refer to how '&' affects process state in step 1 of execution_table.
Concept Snapshot
Process control manages running programs by starting, pausing, resuming, and terminating them.
In Linux shell, '&' runs a program in background allowing shell to continue.
'kill' command sends signals to control processes.
'ps' lists running processes.
Process ends when terminated or completed.
Full Transcript
When you start a program in Linux, the shell creates a process to run it. If you add '&' at the end, the program runs in the background, letting you keep using the shell. You can see running processes with 'ps'. To stop a process, you use 'kill' with the job ID. After killing, the process ends and disappears from the list. This is how process control manages running programs, letting you start, pause, resume, or stop them as needed.

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