After this lesson, you will be able to: Inspect and manage Linux processes: ps, top, htop, kill, background jobs, and the systemd basics every admin uses.
Every running command is a process. Knowing how to see, find, and stop them is the difference between fixing a stuck server in 30 seconds and rebooting it.
Use ps for snapshots, top/htop for live views.
ps # processes in your current shellps aux # ALL processes, full infops aux | grep nginx # filter by nameps -ef --forest # tree view (parent → child)top # live process view (q to quit)htop # nicer; install with apt or brew# Show the top 5 CPU eatersps -eo pid,user,%cpu,%mem,cmd --sort=-%cpu | head -n 6
Kill sends signals; the default (SIGTERM) is polite, SIGKILL is brutal.
kill 12345 # SIGTERM (graceful)kill -TERM 12345 # same as abovekill -KILL 12345 # SIGKILL (force, no cleanup)kill -9 12345 # same (9 = SIGKILL)kill -HUP 12345 # SIGHUP (re-read config, used by nginx etc)pkill nginx # kill all processes named nginxkillall -9 chromium # killall by name with SIGKILL# Always try SIGTERM first; SIGKILL leaves files / locks in bad state
Run things in the background; bring them forward when needed.
long-command & # run in backgroundjobs # list background jobsfg %1 # bring job 1 to foregroundbg %1 # resume job 1 in backgroundCtrl-Z # suspend current foreground jobCtrl-C # send SIGINT (stop running)nohup long-command & # run detached from your shell# Even better:screen / tmux # persistent shell sessions that survive disconnect
Almost every Linux distro since 2015 uses systemd to manage services (background processes). A 'unit file' (e.g. `/etc/systemd/system/myapp.service`) describes how to start, stop, restart, and depend on your service. systemctl is the CLI: `systemctl start nginx`, `systemctl status nginx`, `systemctl enable nginx` (start on boot). journalctl reads systemd logs: `journalctl -u nginx -f` follows nginx logs.
Drop this in /etc/systemd/system/myapp.service to manage a Node.js app.
[Unit]Description=My Node.js appAfter=network.target[Service]Type=simpleUser=myappWorkingDirectory=/srv/myappExecStart=/usr/bin/node server.jsRestart=on-failureRestartSec=5Environment=NODE_ENV=productionEnvironmentFile=/etc/myapp/env[Install]WantedBy=multi-user.target# After saving:# sudo systemctl daemon-reload# sudo systemctl enable myapp# sudo systemctl start myapp# sudo systemctl status myapp# sudo journalctl -u myapp -f
Killing with -9 by default. Always try SIGTERM first; SIGKILL leaves locks and temp files behind. Running long jobs in foreground shells. Lose SSH = lose job. Use tmux or systemd. Skipping `systemctl daemon-reload` after editing unit files; systemd uses the cached old version. Forgetting `Restart=on-failure` in services. Systemd is your free auto-restart; use it. Not setting a non-root `User=` in services. Run apps as a dedicated user, not root.
Pick the safe, professional sequence.
Sign in and purchase access to unlock this lesson.