💥 Command: kill (Terminate a Process)
The kill command is used to send a signal to a running process, usually with the intent to stop it. Despite its aggressive name, it is a communication tool—you are essentially sending a message to a program’s Process ID (PID).
1. The "Why"
Even on a stable system like Arch Linux, applications can freeze or misbehave.
- Stop a Frozen App: If a project build hangs and stops responding.
- Force a Config Reload: Some background services restart or reload their settings when they receive a specific "kill" signal.
- Clean Up: Closing background tasks that you no longer need but that didn't close properly when you exited the GUI.
2. Basic Syntax
kill [SIGNAL] PID
- PID: The Process ID you found using
psorpgrep. - Signal: The type of "message" you want to send (defaults to
15if not specified).
3. The Most Common Signals
There are many signals, but you only need to remember these three:
| Signal | Name | What it does |
|---|---|---|
| 15 | SIGTERM |
The Polite Way. Asks the program to save its data and close gracefully. (Default) |
| 9 | SIGKILL |
The Forced Way. Kills the program instantly. The program has no chance to save anything. Use only if 15 fails. |
| 1 | SIGHUP |
The Reload. Often used to tell a service to "Hang Up" and restart its configuration. |
4. Practical Examples
A. The Polite Kill
Suppose you found that your PDF viewer has a PID of 1234. Try this first:
kill 1234
B. The "Nuclear" Option
If the program is completely frozen and ignoring you, use signal 9:
kill -9 1234
C. Killing by Name (pkill)
If you don't want to look up the PID, you can use pkill to target the process name directly:
pkill java
D. Killing Everything with a Specific Name (killall)
If you have five instances of a program running and want them all gone:
killall firefox
5. Pro-Tips
- Permissions: You can only kill processes that you own. If a process is owned by
root(like a system service), you must usesudo kill. - Don't start with -9: Always try a standard
kill(signal 15) first. Using-9(SIGKILL) can sometimes leave "zombie" processes or corrupted files because the app didn't get to finish its cleanup. - Arch Linux Context: If your Hyprland bar (Waybar) freezes after an update, you can simply run
pkill waybarand then start it again from your terminal or runner.
6. Summary Reference
| Goal | Command |
|---|---|
| Stop a process politely | kill PID |
| Force a process to stop | kill -9 PID |
| Kill by program name | pkill name |
| Kill all instances by name | killall name |
| Find PID and kill in one go | kill $(pgrep name) |