Home / System Administration / kill / killall

kill / killall

Terminate Processes by PID or Name

What Does It Do?

The kill and killall commands are used to terminate processes on Linux. kill targets processes by their PID (Process ID), while killall terminates all processes matching a specific name.

Think of these commands as your process control tools. When an application freezes, becomes unresponsive, or you need to stop a service, kill sends signals to processes telling them to terminate. The default signal is SIGTERM (15), which asks the process to gracefully shut down, clean up resources, and exit. If a process ignores SIGTERM, you can escalate to SIGKILL (9) with kill -9, which forcefully terminates it without cleanup—use this as a last resort. killall is convenient when you want to terminate all instances of an application by name (e.g., killall firefox stops all Firefox processes). Admins use these commands daily to manage runaway processes, stop malware, or restart services. Always try SIGTERM first—it's cleaner and safer than SIGKILL.

Advertisement

When Should I Use It?

Stop Frozen Applications

Terminate unresponsive programs that won't close normally.

Control Runaway Processes

Stop processes consuming excessive CPU or memory.

Terminate Malware

Stop malicious processes during incident response.

Restart Services

Stop services before restarting them with systemctl.

Common Commands

kill 1234

Send SIGTERM (graceful termination) to process with PID 1234.

kill -9 5678

Send SIGKILL (force kill) to process with PID 5678.

killall firefox

Terminate all processes named "firefox".

killall -9 chrome

Force kill all Chrome processes.

sudo kill 892

Kill a system process (requires root privileges).

kill -STOP 3456

Pause (suspend) a process with PID 3456.

kill -CONT 3456

Resume a paused process with PID 3456.

UNDERSTANDING SIGNALS

SIGTERM (15): Default signal. Asks process to terminate gracefully. Process can catch this signal and clean up before exiting.

SIGKILL (9): Force kill. Process cannot catch or ignore this signal. Use when SIGTERM fails, but it may leave resources uncleaned.

SIGHUP (1): Hangup signal. Often used to reload configuration files without restarting the process.

SIGSTOP (19) / SIGCONT (18): Pause and resume processes without terminating them.

Best practice: Always try kill PID first (SIGTERM). Only escalate to kill -9 (SIGKILL) if the process refuses to die.

IMPORTANT WARNINGS

Never kill PID 1 (init/systemd): PID 1 is the init process that manages all other processes. Killing it will crash your entire system.

Use SIGKILL sparingly: kill -9 doesn't allow processes to clean up. They can't save data, release locks, or close files properly. Data corruption is possible.

Root privileges required: You can only kill your own processes unless you're root. System processes require sudo.

Double-check PIDs: Before killing, verify the PID with ps aux. Killing the wrong process can cause system instability.

Try It Yourself

Practice kill and killall commands in the interactive terminal below: