Processes, ports and jobs
Inspecting what runs, stopping it gracefully, checking which port is busy, and keeping work alive after logout.
What is running
ps aux | grep nginx
top # live overview, q to quit
htop # friendlier top (install if missing)
pgrep -l node
pstree -p | head # parent/child relationships| Column in ps aux | Meaning |
|---|---|
USER | Owner of the process |
%CPU / %MEM | Resource usage |
PID | Process id β how you target it |
STAT | State; useful when diagnosing zombies |
Stopping processes
kill 1234 # SIGTERM - polite request to stop
kill -9 1234 # SIGKILL - cannot be caught, use last
pkill -f 'node app'
killall nginxβ οΈ
Always try
SIGTERM before -9. Killing outright skips cleanup, which can leave locks, partial writes, or orphaned children behind.Ports and connections
ss -ltnp # listening TCP ports + process
lsof -i :3000 # who owns port 3000
ss -tuln
curl -I localhost:3000 # quick health check
curl -s -o /dev/null -w '%{http_code} %{time_total}s\n' https://example.com'Address already in use' means something holds the port. Find it with lsof -i :PORT rather than blindly restarting.
Background jobs
long-task & # run in background
Ctrl-Z # suspend the foreground job
bg # resume it in the background
fg # bring it back to foreground
jobs # list
nohup ./serve.sh > serve.log 2>&1 & # survives logout
# or use tmux/screen for a real sessionBackground jobs started with & still belong to your shell; nohup ignores hangup signals. For long-lived work, tmux is more robust than either.
FAQ
Process will not die even after kill -9?
It may be a zombie waiting to be reaped by its parent, or blocked in uninterruptible I/O (often NFS). Check
STAT in ps aux.How do I see what a service logged?
With systemd:
journalctl -u nginx -f. Otherwise check /var/log/.Related
SSH, packages and services Files and permissions
Last refreshed 2026-09-17.