NCAE Mapping Hub
Overview Scoreboard Data Roles Exercised Checklists Lessons Skill Drills Practice Terminal Progress
published priority 10 25 min. 40 XP.

Linux Service Management. systemctl, journalctl, sysvinit

Every NCAE service is managed by systemd. You will type `systemctl restart <service>` at least once per minute during competition. This lesson is the foundation. without it, nothing in the other lessons makes sense. It also teaches `journalctl`, which is where you find out why a service REFUSES to start.

DCWF roles: IT-411 Technical Support Specialist IT-451 System Administrator Services: SSH LoginSMB LoginDNS INT FWDPostgres AccessWWW Port 80WWW ContentWWW SSL

Objectives

Quick reference

CommandPurpose
systemctl status <svc> Current status + last few log lines
systemctl start <svc> Start the service now
systemctl stop <svc> Stop it now
systemctl restart <svc> Stop then start
systemctl reload <svc> Apply config changes without stopping (if supported)
systemctl reload-or-restart <svc> Prefer reload; fall back to restart
systemctl enable <svc> Auto-start on boot
systemctl disable <svc> Don't auto-start on boot
systemctl is-active <svc> Exits 0 if active. useful in scripts
systemctl list-unit-files --type=service --state=enabled All enabled services
systemctl list-timers --all All systemd timers
systemctl cat <svc> Print the unit file contents
systemctl daemon-reload Re-read unit files after editing them
journalctl -u <svc> All logs from a service
journalctl -u <svc> -n 50 Last 50 lines
journalctl -u <svc> -f Follow in real time (tail -f)
journalctl -u <svc> --since '5 minutes ago' Time-filtered
journalctl -p err --since today All errors today, any unit

Common pitfalls

How it works (walkthrough)

# A minimal systemd service unit file
# /etc/systemd/system/my-watchdog.service
[Unit]
Description=Keep the tarball restore loop alive
After=network.target

[Service]
Type=simple
ExecStart=/root/restore-loop.sh
Restart=always                 # if it dies, systemd restarts it
RestartSec=2

[Install]
WantedBy=multi-user.target      # start on boot at multi-user runlevel

# After writing the file:
#   systemctl daemon-reload         # pick up the new file
#   systemctl enable --now my-watchdog

Skill drills

  1. 1. Command to check if nginx is currently running?
    systemctl status nginx (or is-active nginx)
  2. 2. Command to reload nginx without restarting?
    systemctl reload nginx
  3. 3. Command to see why a service refused to start?
    journalctl -u <svc> -n 50
  4. 4. After editing /etc/systemd/system/foo.service, what must you run?
    systemctl daemon-reload
  5. 5. What runlevel does `multi-user.target` correspond to in sysvinit?
    Runlevel 3 (multi-user, no GUI)
  6. 6. Follow the sshd log in real time?
    journalctl -u sshd -f

NCAE scoreboard patterns this lesson prevents