Skip to main content
SysAdmin Shell Scripting Essentials

Kill Process In Linux: CLI Command Reference, Syntax, Flags

kill process in linux uses the kill command to send signals (default SIGTERM) to processes identified by PID, enabling graceful or forced termination, pausing, or restarting from the command line.

ps aux | grep firefox   # Find PID
kill 22673              # Send SIGTERM (default)
kill -9 22673           # Force kill with SIGKILL

kill is a built-in Linux utility (/bin/kill) for sending signals to processes. It is the standard method to terminate misbehaving or stuck processes, using PID values obtained from ps, pgrep, or top. Typical scenarios include terminating a hung Firefox process (SIGTERM), force killing a stuck Chrome tab (SIGKILL), or reloading a daemon’s configuration (SIGHUP). The command is POSIX-compliant and works on every Linux distribution.

Syntax

kill [-signal] [signal-number] <PID>
kill -l [exit-status]
Form Description
kill -TERM 1234 Send SIGTERM (default) to PID 1234
kill -9 1234 Send SIGKILL to PID 1234
kill -l List all available signal names
kill -15 1234 Same as SIGTERM (15)
kill -HUP 1234 Send SIGHUP to reload config

Options and Flags

Flag Description
-l Print a list of signal names (with optional exit status mapping)
-s signal Specify the signal by name or number (e.g., -s SIGTERM)
-n Do not display error messages when a process does not exist
See also  Execute PowerShell Script from PowerShell: Call Operator

>

Usage Examples

Example 1: Gracefully terminate Firefox

ps aux | grep firefox
kill -15 22673   # Send SIGTERM
ps aux | grep firefox   # Verify termination

ps aux lists all processes including Firefox’s PID. kill -15 (equivalent to kill without signal) asks Firefox to clean up and exit. The second ps confirms the process is gone. Use SIGTERM first; it allows the process to flush buffers and release resources.

Example 2: Force kill an unresponsive process

# Identify Chrome PID(s)
ps aux | grep chrome
# Force kill all PIDs
kill -9 3827
kill -9 3919
kill -9 10764
kill -9 11679

When a process ignores SIGTERM (e.g., Chrome tab crash), kill -9 (SIGKILL) terminates it immediately. The process cannot catch or ignore SIGKILL, making it the last resort. Running multiple kill commands against each PID is safe; if a PID no longer exists, kill returns an error but does not affect other processes.

Example 3: Kill all processes owned by a specific user

# Using ps and awk to get PIDs
ps -fu justin | awk 'NR>1 {print $2}' | xargs kill -15

ps -fu justin lists all processes of user “justin”. awk extracts the second column (PID) and pipes to xargs kill. This approach sends SIGTERM to all matching processes. For force kill, replace -15 with -9.

Troubleshooting & Common Errors

Error Message / Symptom Root Cause Resolution Command
kill: (PID) - No such process Process already exited or PID stale ps aux | grep [name] to re-identify
Operation not permitted Insufficient privileges (e.g., killing root-owned process as user) sudo kill -9 [PID]
kill: invalid signal specification: 'term' (when using -l incorrectly) Using -l with a PID instead of signal name kill -l alone to list signals
kill: usage: kill [-s signal] pid ... Incorrect syntax, e.g., missing PID Provide a valid PID
Process still running after kill (no error) Signal blocked or ignored; process in uninterruptible sleep (D state) Use kill -9 or reboot if necessary
See also  Linux nc Command Reference (Netcat): Usage, Examples, and

Closing Tip

Always try kill -15 (SIGTERM) before escalating to kill -9; many processes save state on SIGTERM, and forcing a kill may lead to data loss or locked files.

Frequently Asked Questions

What is the difference between kill -9 and kill -15?

Answer: kill -15 (SIGTERM) requests graceful termination; kill -9 (SIGKILL) forcibly kills immediately, bypassing cleanup handlers.

SIGTERM (default) allows processes to handle the signal, flush buffers, and exit cleanly. SIGKILL cannot be caught or ignored, leaving data at risk. Use SIGTERM first; only escalate to SIGKILL if the process ignores repeated SIGTERM signals.

kill -15 1234   # SIGTERM (default)
kill -9 1234    # SIGKILL (forced)

How do I fix “Operation not permitted” when trying to kill a process?

Answer: Grant yourself the same user as the target process, use sudo, or check if the process is zombie (already dead).

Non-root users can only kill their own processes. If you see “Operation not permitted”, re-run as root (sudo kill -15 PID) or verify the process belongs to you with ps aux | grep PID. Zombies cannot be killed; you must wait on the parent or kill the parent process.

sudo kill -15 1234   # escalate to root
kill -15 $(ps -o pid= --ppid )  # kill parent to reap zombie

Does the kill command work on all Linux distributions?

Answer: Yes.

The core kill utility comes from procps-ng (glibc-based) or busybox (Alpine). Flags -15, -9, -l are universal. However, killall and pkill may have subtle behavior differences across distros; always check man pages on the target system.

which kill      # /usr/bin/kill
kill -l         # list all signal names (POSIX portable)