# A practical guide to killing unresponsive processes in Linux. Learn to use `kill`,
# `killall`, `pkill`, and `fuser` to stop processes by PID, name, or network port.
# ----- Kill by Process ID (PID) - The Classic Way -----
# First, find the Process ID (PID) of your app:
xinit@localhost:~$ ps aux | grep 'my_process'
# Then, kill the process by its PID:
# Sends a "graceful shutdown" signal (SIGTERM 15)
xinit@localhost:~$ kill PID_NUMBER
# If it doesn't work, force kill the process:
# Sends an "ungraceful kill" signal (SIGKILL 9)
xinit@localhost:~$ kill -9 PID_NUMBER
# ----- Kill by Name (pkill & killall) - The Convenient Way -----
# Kill a process by its exact name:
# Note: killall is very strict with the name
xinit@localhost:~$ killall my_process
# Force kill a process by its exact name:
xinit@localhost:~$ killall -9 my_process
# A more flexible way to kill by name (finds partial matches):
xinit@localhost:~$ pkill -f 'my_process_or_script.py'
# ----- Kill by Port Usage - The Network Way -----
# Find and kill the process using a specific port (e.g., 8443):
# The '-k' option sends the SIGKILL signal by default
xinit@localhost:~$ fuser -k 8443/tcp