Bird
Raised Fist0
Linux CLIscripting~20 mins

kill and signal types in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Signal Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of sending SIGTERM to a process?
You run the command kill -15 1234 to send a SIGTERM signal to process 1234. What is the expected behavior if the process handles SIGTERM properly?
AThe process terminates gracefully, cleaning up resources before exiting.
BThe process immediately stops without cleanup.
CThe process ignores the signal and continues running.
DThe system restarts the process automatically.
Attempts:
2 left
💡 Hint
SIGTERM is a polite request to terminate a process.
💻 Command Output
intermediate
2:00remaining
What happens when you send SIGKILL to a process?
You execute kill -9 5678 to send SIGKILL to process 5678. What is the immediate effect?
AThe process ignores the signal and continues running.
BThe process is immediately terminated by the kernel without cleanup.
CThe process receives a chance to save data before exiting.
DThe process restarts automatically after termination.
Attempts:
2 left
💡 Hint
SIGKILL cannot be caught or ignored.
📝 Syntax
advanced
2:00remaining
Which kill command syntax sends SIGUSR1 to process 4321?
Choose the correct command to send the SIGUSR1 signal to process ID 4321.
Akill -usr1 4321
Bkill -SIGUSR1 4321
Ckill -signal SIGUSR1 4321
Dkill -s SIGUSR1 4321
Attempts:
2 left
💡 Hint
Use the -s option to specify signal by name.
🔧 Debug
advanced
2:00remaining
Why does kill -15 without a PID fail?
You run kill -15 without specifying a process ID. What error or behavior occurs?
Akill reports 'usage error' because PID is missing.
Bkill sends SIGTERM to all processes owned by the user.
Ckill sends SIGTERM to the shell itself.
Dkill silently does nothing and exits with success.
Attempts:
2 left
💡 Hint
kill requires a PID argument to know which process to signal.
🧠 Conceptual
expert
3:00remaining
What signal number corresponds to SIGSTOP and what is its effect?
Identify the signal number for SIGSTOP and explain what happens to a process when it receives this signal.
ASignal 15; the process terminates gracefully.
BSignal 9; the process is terminated immediately.
CSignal 19; the process is paused and can be resumed later.
DSignal 1; the process ignores the signal.
Attempts:
2 left
💡 Hint
SIGSTOP pauses a process without terminating it.

Practice

(1/5)
1. What is the default signal sent by the kill command if no signal is specified?
easy
A. SIGINT (interrupt the process)
B. SIGTERM (terminate gracefully)
C. SIGSTOP (pause the process)
D. SIGKILL (force kill immediately)

Solution

  1. Step 1: Understand the default behavior of kill

    The kill command sends signals to processes. If no signal is specified, it sends the default signal.
  2. Step 2: Identify the default signal

    The default signal is SIGTERM, which asks the process to terminate gracefully, allowing cleanup.
  3. Final Answer:

    SIGTERM (terminate gracefully) -> Option B
  4. Quick Check:

    Default kill signal = SIGTERM [OK]
Hint: Remember: kill defaults to SIGTERM for polite stop [OK]
Common Mistakes:
  • Confusing SIGKILL as default signal
  • Thinking SIGSTOP pauses instead of terminates
  • Assuming SIGINT is default for kill
2. Which of the following is the correct syntax to send a SIGKILL signal to a process with PID 1234?
easy
A. kill 1234 -9
B. kill 1234 -s SIGKILL
C. kill 1234 -SIGKILL
D. kill -9 1234

Solution

  1. Step 1: Recall the syntax for sending signals with kill

    The kill command can use -s SIGNAL or numeric signal with a dash before the number.
  2. Step 2: Identify the correct numeric signal and position

    -9 is the numeric code for SIGKILL. The correct syntax is kill -9 PID. All other options incorrectly place the signal specification after the PID, which is invalid syntax.
  3. Final Answer:

    kill -9 1234 -> Option D
  4. Quick Check:

    kill -9 PID sends SIGKILL [OK]
Hint: Use kill -9 PID to force kill quickly [OK]
Common Mistakes:
  • Placing signal after PID
  • Using -SIGKILL instead of -s SIGKILL
  • Confusing signal names and numbers
3. What will be the output of the following command sequence?
sleep 100 &
kill -15 $!

Assuming $! is the PID of the sleep process.
medium
A. The sleep process stops gracefully after receiving SIGTERM
B. The sleep process is immediately killed without cleanup
C. The sleep process ignores the signal and continues running
D. Syntax error due to incorrect kill command

Solution

  1. Step 1: Understand the commands

    sleep 100 & runs sleep in background. $! stores its PID. kill -15 $! sends SIGTERM (signal 15) to that PID.
  2. Step 2: Effect of SIGTERM on sleep

    SIGTERM asks the process to stop gracefully. Sleep will stop waiting and exit cleanly.
  3. Final Answer:

    The sleep process stops gracefully after receiving SIGTERM -> Option A
  4. Quick Check:

    kill -15 sends SIGTERM = graceful stop [OK]
Hint: Signal 15 (SIGTERM) politely stops processes [OK]
Common Mistakes:
  • Confusing SIGTERM with SIGKILL immediate stop
  • Assuming sleep ignores SIGTERM
  • Thinking kill command syntax is wrong
4. You try to stop a stubborn process with kill -15 5678 but it keeps running. What is the best fix?
medium
A. Use kill -1 5678 to send SIGHUP
B. Restart the system to clear the process
C. Use kill -9 5678 to force kill immediately
D. Use kill 5678 without signal

Solution

  1. Step 1: Understand why SIGTERM might fail

    SIGTERM (signal 15) asks process to stop nicely, but some processes ignore or handle it differently.
  2. Step 2: Use SIGKILL to force stop

    SIGKILL (signal 9) forces immediate termination and cannot be ignored. Using kill -9 is the best fix for stubborn processes.
  3. Final Answer:

    Use kill -9 5678 to force kill immediately -> Option C
  4. Quick Check:

    kill -9 forces stop when SIGTERM fails [OK]
Hint: If kill -15 fails, try kill -9 to force stop [OK]
Common Mistakes:
  • Using kill without signal defaults to SIGTERM
  • Using SIGHUP does not force stop
  • Restarting system is last resort, not first
5. You want to pause a process with PID 4321 temporarily and then resume it later. Which signals should you send in order?
hard
A. Send SIGSTOP to pause, then SIGCONT to resume
B. Send SIGTERM to pause, then SIGKILL to resume
C. Send SIGKILL to pause, then SIGSTOP to resume
D. Send SIGINT to pause, then SIGTERM to resume

Solution

  1. Step 1: Identify signals to pause and resume

    SIGSTOP pauses a process immediately without termination. SIGCONT resumes a paused process.
  2. Step 2: Understand incorrect options

    SIGTERM and SIGKILL terminate processes, not pause or resume. SIGINT interrupts but does not pause/resume.
  3. Final Answer:

    Send SIGSTOP to pause, then SIGCONT to resume -> Option A
  4. Quick Check:

    Pause = SIGSTOP, Resume = SIGCONT [OK]
Hint: Pause with SIGSTOP, resume with SIGCONT signals [OK]
Common Mistakes:
  • Using SIGTERM or SIGKILL to pause processes
  • Confusing SIGINT with pause/resume signals
  • Thinking kill without signal pauses process
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