pgrep -a python or ps aux | grep python, then run kill 12345. That sends SIGTERM, which asks the program to close cleanly. If it is still running after a few seconds, force it with kill -9 12345 (SIGKILL). Use sudo for processes owned by other users, and stop services with systemctl stop rather than kill.
Before you start
- Connect with SSH.
- You can kill your own processes. Processes owned by root or other users need
sudo(root can leave it out). - If the program is a service (nginx, MariaDB, a game server unit), use
sudo systemctl stop nameorrestart. systemd restarts many killed services automatically. See manage services with systemctl.
How to find the process ID (PID)
- By name
- With ps
- By port
- By resource use
How to kill a process by PID
1
Ask it to stop
2
Check it is gone
3
Force it if needed
If it is still running after 5 to 10 seconds:SIGKILL (signal 9) stops it instantly. The program can’t clean up, so unsaved data is lost.
Common signals
Use the name or the number:
kill -HUP 1204 and kill -1 1204 are the same. kill -l lists all signals.
How to kill a process by name
pkill and killall send SIGTERM too; add -9 to force.
On AlmaLinux and Rocky Linux, killall comes from the psmisc package: sudo dnf install psmisc.
What to do if a process won’t die
Check the state with
ps -o pid,stat,cmd -p 30043. The STAT column shows D, Z, S (sleeping) or R (running).
How to check it worked
no process running. If you killed a program to free a port, sudo ss -tlnp 'sport = :8080' should show only the header line.
Frequently asked questions
What is the difference between kill, pkill and killall?
kill takes a PID. pkill takes a pattern and matches part of the name (or the full command line with -f). killall matches the exact process name.
How do I kill all processes of one user?
Runsudo pkill -u alex to send SIGTERM to all of alex’s processes. This also ends their SSH sessions.
How do I kill a process that is using a port?
Find it withsudo lsof -i :8080 -t (prints only the PID) and kill it: sudo kill $(sudo lsof -i :8080 -t). Check the PID first if it might be a service.
My server is out of memory and processes keep getting killed. Why?
That is the kernel’s out-of-memory (OOM) killer. See fix out of memory killed processes and check memory usage.Related guides
VPS and dedicated server guides
Every server guide in one place.
Monitor resources with htop
Find and kill processes visually.
Find what is using CPU
Track down a busy process.
Manage services with systemctl
Stop services the right way.
Check open ports
Find what holds a port.
Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026