Module 4: The system
Services: systemctl and journalctl
Web servers, databases and SSH all run as services, and systemd looks after them. This is the first place to look when something on a server stops working.
● Runs 100% in your browser. Nothing here can harm a real system.
Step 1 of 6
Is it running?
systemctl status shows whether a service is running, since when, and its last log lines. You don't need sudo just to look.
Your task
Check the status of nginx.
guest@ohsudo: ~ — Ubuntu 24.04
Starting the terminal…
What you'll practice
- Is it running?.
systemctl statusshows whether a service is running, since when, and its last log lines. You don't needsudojust to look. - Stop it. Changing a service needs root, so this is where
sudocomes in. A command that succeeds here prints nothing, which is normal on Linux. - See the effect.
curlmakes a web request from the command line. With Nginx stopped, nothing listens on port 80, so the connection is refused. - Start it again.
startruns it now, andenablemakes it start at boot. They're separate, andsudo systemctl enable --nowdoes both. - Names differ. Some services have other names between distributions. On Debian and Ubuntu, the SSH server is
ssh. Some services have other names between distributions. On RHEL, Rocky and AlmaLinux the SSH server issshd, notssh, and cron iscrond, notcron. - Read its log.
journalctl -ushows the log of one service.-nlimits it to the last lines, and--no-pagerprints it straight out, which suits copying into a message.