You send the process a signal. kill PID sends SIGTERM by default, which asks the process to exit so it can close files and clean up. If it does not exit, kill -9 sends SIGKILL. The process cannot catch or ignore it, so the kernel ends it with no chance to clean up.
To act by name instead of process ID, pkill matches a pattern and killall matches an exact name.
Signals do other jobs too. SIGHUP often tells a daemon to reload its configuration, and SIGSTOP and SIGCONT pause and resume a process. kill -l lists them all.
# Kill by PID
kill PID # Send TERM signal (15)
kill -9 PID # Send KILL signal (forceful)
kill -15 PID # Send TERM signal (graceful)
# Kill by name
killall process_name # Kill all processes with name
pkill pattern # Kill processes matching pattern
# Common signals
kill -l # List all signals
kill -HUP PID # Reload configuration (1)
kill -INT PID # Interrupt (2)
kill -QUIT PID # Quit (3)
kill -KILL PID # Force kill (9)
kill -TERM PID # Terminate (15)
kill -STOP PID # Stop process (19)
kill -CONT PID # Continue process (18)
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓