In Unix/Linux process control, which command is commonly used to terminate a running process by sending a signal (for example, SIGTERM or SIGKILL)?
-
Akill
-
Bshutdown
-
Chaltsys
-
Dcancel
-
ENone of the above
Answer
Correct Answer: kill
Explanation
Introduction / Context:When a program hangs or must be stopped, Unix/Linux provides a signal mechanism to request termination. The standard user-space tool to send signals to processes—whether gentle or forceful—is fundamental for administration and scripting.
Given Data / Assumptions:
- You know the process ID (PID) or can find it with 'ps'/'pgrep'.
- You want to end the process cleanly if possible.
- You have appropriate permissions to signal the process.
Concept / Approach:Use 'kill PID' to send SIGTERM (15) by default, allowing the process to exit gracefully. If it does not respond, 'kill -9 PID' sends SIGKILL, which the process cannot catch or ignore. Other signals like SIGHUP can request reloads. The 'kill' command is versatile and supports multiple PIDs and process group signaling.
Step-by-Step Solution:
Identify the PID: ps -ef | grep appname or pgrep appnameTry graceful stop: killVerification / Alternative check:Check logs or process status post-signal. For services managed by init/systemd, use service-aware tools (for example, 'systemctl stop') which may call 'kill' under the hood.
Why Other Options Are Wrong:
- shutdown / haltsys: System-level power management, not per-process termination.
- cancel: Not a standard Unix signal-sending command.
- None of the above: Incorrect because 'kill' is correct.
Common Pitfalls:Overusing '-9' which bypasses cleanup, signaling the wrong PID, or failing to consider service managers that auto-respawn processes.
Final Answer:kill