View running processes, manage them, control services with systemctl, and monitor disk and memory.
Processes and System Monitoring is one of the most important topics in Linux in 5 Days. This lesson builds the foundation you need before moving to more advanced concepts — take time with each example and run the code yourself.
# List all processes ps aux # ps aux | grep nginx ← find a specific process # Interactive process viewer top # built-in, Ctrl+C to exit htop # prettier version (install if needed) # htop keys: # F9 = kill process # F6 = sort by column # / = search
# Get PID from ps aux output kill 1234 # send SIGTERM (graceful) kill -9 1234 # send SIGKILL (force kill) killall nginx # kill all processes named nginx pkill -f 'python app' # kill by command pattern # Background jobs sleep 60 & # run in background jobs # list background jobs fg %1 # bring job 1 to foreground bg %1 # continue job 1 in background
# Start/stop/restart sudo systemctl start nginx sudo systemctl stop nginx sudo systemctl restart nginx sudo systemctl reload nginx # reload config without restart # Enable/disable on boot sudo systemctl enable nginx sudo systemctl disable nginx # Check status systemctl status nginx journalctl -u nginx -f # follow nginx logs
df -h # disk usage by filesystem du -sh ./mydir/ # size of a directory du -sh * | sort -h # sizes of all items, sorted free -h # memory usage cat /proc/meminfo # detailed memory info # Find large files du -ah . | sort -rh | head -20
Before moving on, make sure you can answer these without looking: