Linux: Processes and Services
See what's running, stop what shouldn't be, and manage services with systemd.
Every running program is a process. Knowing how to inspect them helps you spot malware, debug services, and understand what a compromised machine is doing.
1
Inspecting processes
ps auxlists every process with its user, PID (process ID), CPU, memory, and command.top(or the friendlierhtop) shows processes live, sorted by CPU use.pgrep sshdfinds the PID of processes by name.
$ ps aux | grep nginx root 812 0.0 0.1 nginx: master process www-data 813 0.0 0.2 nginx: worker processNote the web server workers run as
www-data, not root: if the site is hacked, the attacker gets only that user's rights.2
Signals and services
kill PIDsends a signal to a process. By default it's SIGTERM (15): please exit. If a process ignores it, SIGKILL (9) ends it immediately and can't be ignored:kill 813 kill -9 813Long-running background programs are services (daemons). Most distributions manage them with systemd:
systemctl status ssh sudo systemctl restart nginx sudo systemctl enable --now fail2ban # start now and at every boot
โ Report a problem with this room
Log in to report a problem.