What I Wanted to Do

A process was hanging and I needed to identify and kill it without rebooting the server.

Check Running Processes

ps aux                    # List all processes
ps aux | grep nginx       # Filter by process name
top                       # Real-time monitor (press q to quit)

Kill a Process

kill PID                  # Request graceful shutdown
kill -9 PID               # Force kill
pkill nginx               # Kill by process name

Find Which Process Is Using a Port

lsof -i :8080
ss -tlnp | grep 8080

Common Pitfalls

  • If kill alone doesn’t work, use kill -9 — but treat it as a last resort
  • For services like nginx or Docker, using systemctl stop is safer than killing the process directly

For managing services via systemd, see Manage Services with systemd (start/stop/enable/status).

Looking for reliable cloud infrastructure? Check out these developer-friendly services.