How to manage systemd services in Linux

· Category: Linux

Short answer

Use systemctl to control services and journalctl to view their logs on systemd-based Linux systems.

Steps

  1. Start a service:
sudo systemctl start nginx
  1. Enable at boot:
sudo systemctl enable nginx
  1. Check status:
sudo systemctl status nginx
  1. Restart:
sudo systemctl restart nginx
  1. View logs:
sudo journalctl -u nginx -f

Tips

  • systemctl list-units --type=service shows active services.
  • systemctl daemon-reload applies unit file changes.
  • Use journalctl --since "1 hour ago" for time-based log filtering.

Common issues

  • Syntax errors in unit files prevent daemon-reload from succeeding.
  • Missing permissions: most service commands require root or sudo.