Skip to content
ohsudo, Home

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

  1. 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.
  2. Stop it. Changing a service needs root, so this is where sudo comes in. A command that succeeds here prints nothing, which is normal on Linux.
  3. See the effect. curl makes a web request from the command line. With Nginx stopped, nothing listens on port 80, so the connection is refused.
  4. Start it again. start runs it now, and enable makes it start at boot. They're separate, and sudo systemctl enable --now does both.
  5. 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 is sshd, not ssh, and cron is crond, not cron.
  6. Read its log. journalctl -u shows the log of one service. -n limits it to the last lines, and --no-pager prints it straight out, which suits copying into a message.

See also