0
0
Linux CLIscripting~10 mins

kill and signal types in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - kill and signal types
Start: Identify process
Choose signal type
Send signal with kill command
Process receives signal
Process reacts: terminate, pause, ignore, etc.
End: Signal effect observed
The flow shows how you pick a process, choose a signal, send it with kill, and the process reacts accordingly.
Execution Sample
Linux CLI
kill -SIGTERM 1234
kill -9 1234
kill -SIGSTOP 1234
Send different signals (terminate, force kill, stop) to process with ID 1234.
Execution Table
StepCommandSignal SentProcess ReactionOutput/Result
1kill -SIGTERM 1234SIGTERM (15)Process requests graceful shutdownNo output if successful
2kill -9 1234SIGKILL (9)Process immediately terminatesNo output if successful
3kill -SIGSTOP 1234SIGSTOP (19)Process pauses (stops execution)No output if successful
4kill -SIGCONT 1234SIGCONT (18)Process resumes executionNo output if successful
5kill -SIGINT 1234SIGINT (2)Process interrupts (like Ctrl+C)No output if successful
6kill -SIGUSR1 1234SIGUSR1 (10)Process handles user-defined signalNo output if successful
7kill -SIGTERM 999999SIGTERM (15)No such processkill: (999999) - No such process
💡 Execution stops after all signals sent or if process does not exist.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6After Step 7
Process StateRunningGraceful shutdown requestedTerminatedPausedResumedInterruptedUser signal handledNo process found
Key Moments - 3 Insights
Why does kill -9 immediately stop the process while kill -SIGTERM allows it to clean up?
kill -9 sends SIGKILL which cannot be caught or ignored, forcing immediate termination. kill -SIGTERM sends SIGTERM which the process can catch and handle to clean up before exiting, as shown in steps 1 and 2 of the execution_table.
What happens if you send a signal to a process ID that does not exist?
The kill command returns an error message like 'No such process' as shown in step 7 of the execution_table, because the system cannot find the process to signal.
How does SIGSTOP differ from SIGTERM in process control?
SIGSTOP pauses the process without terminating it, allowing it to be resumed later with SIGCONT, as shown in steps 3 and 4. SIGTERM requests termination.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what signal does 'kill -9 1234' send?
ASIGKILL (9)
BSIGTERM (15)
CSIGSTOP (19)
DSIGINT (2)
💡 Hint
Check step 2 in the execution_table under 'Signal Sent' column.
At which step does the process get paused?
AStep 1
BStep 3
CStep 5
DStep 7
💡 Hint
Look for 'Paused' in the 'Process Reaction' column in the execution_table.
If you send SIGTERM to a non-existing process, what output do you expect?
AProcess terminates silently
BNo output
Ckill: (999999) - No such process
DProcess pauses
💡 Hint
See step 7 in the execution_table for the error message.
Concept Snapshot
kill command sends signals to processes by PID
Common signals: SIGTERM(15) graceful stop, SIGKILL(9) force stop, SIGSTOP(19) pause
Process reacts based on signal: terminate, pause, ignore
Use kill -SIGNAL PID or kill -number PID
SIGKILL cannot be caught or ignored
SIGSTOP pauses process until SIGCONT resumes it
Full Transcript
This lesson shows how the kill command sends different signals to processes by their ID. First, you identify the process to signal. Then you choose a signal type like SIGTERM to ask the process to stop nicely, or SIGKILL to force it to stop immediately. The process reacts depending on the signal: it may shut down, pause, or ignore it. The execution table traces sending signals like SIGTERM, SIGKILL, SIGSTOP, and SIGCONT to process 1234, showing how the process state changes from running to terminated or paused. If you send a signal to a non-existing process, kill reports an error. Key points include that SIGKILL cannot be caught or ignored, while SIGTERM can be handled by the process. SIGSTOP pauses the process until SIGCONT resumes it. This helps you control processes safely and effectively in Linux.