Watch and control running programs — list processes, monitor the system live with top, run jobs in the background and bring them back, send signals to stop a misbehaving process, and adjust priority.
A process is just a running program. ps aux lists every process on the system with its owner, its process id (PID — the number you use to control it), and how much CPU and memory it is using. It is a snapshot, so pipe it into grep to find the one you care about.
List every process: USER, PID, %CPU, %MEM, and the command
ps auxFind a specific process (here, anything mentioning nginx)
ps aux | grep nginxThe PID is the 2nd column — that's the number you'll use to control it
top is a live, auto-refreshing dashboard of the busiest processes, plus overall CPU and memory use — the first thing to open when a machine feels slow. Press q to quit, M to sort by memory, P to sort by CPU. htop is a nicer, colorful version if it is installed.
Live view of CPU/memory and the busiest processes (q to quit)
topInside top: P = sort by CPU, M = sort by memory, q = quit
A friendlier version (install once with: sudo apt install htop)
htopA long-running command normally holds your terminal hostage until it finishes. Add & to launch it in the background so you get your prompt back. Ctrl+Z pauses ("suspends") whatever is running now; bg resumes it in the background, fg brings it back to the foreground, and jobs lists everything you have backgrounded in this terminal.
Start a command in the background (& returns your prompt immediately)
sleep 300 &List the jobs running in this terminal
jobsPause the foreground command with Ctrl+Z, then:
bg # resume it in the backgroundfg # bring it back to the foregroundYou stop a process by sending it a "signal" — a small message — with kill PID. Plain kill sends TERM, a polite "please shut down" that lets the program clean up. If it ignores that and hangs, kill -9 sends KILL, which the system enforces immediately and the process cannot refuse. Reach for -9 only as a last resort. pkill matches by name instead of PID.
Politely ask a process to stop (sends the TERM signal)
kill 4521Force-kill one that's stuck and ignoring you (last resort)
kill -9 4521Kill by name instead of looking up the PID first
pkill -f "node server.js"Every process has a "niceness" from -20 (greedy, high priority) to 19 (very nice, yields CPU to others). Start a non-urgent job — a big backup or build — with nice so it does not slow down everything else. renice changes the priority of something already running. Raising priority (negative numbers) needs sudo.
Start a heavy job at low priority so it stays out of the way
nice -n 19 tar -czf backup.tar.gz /var/wwwChange the priority of an already-running process by PID
sudo renice -n 10 -p 4521