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
- Start a service:
sudo systemctl start nginx
- Enable at boot:
sudo systemctl enable nginx
- Check status:
sudo systemctl status nginx
- Restart:
sudo systemctl restart nginx
- View logs:
sudo journalctl -u nginx -f
Tips
systemctl list-units --type=serviceshows active services.systemctl daemon-reloadapplies unit file changes.- Use
journalctl --since "1 hour ago"for time-based log filtering.
Common issues
- Syntax errors in unit files prevent
daemon-reloadfrom succeeding. - Missing permissions: most service commands require root or sudo.