systemd Service Management
Managing services with systemctl commands.
Service Control
Start service
sudo systemctl start nginx
Stop service
sudo systemctl stop nginx
Restart service
sudo systemctl restart nginx
Reload configuration
sudo systemctl reload nginx
Enable on boot
sudo systemctl enable nginx
Disable on boot
sudo systemctl disable nginx
Enable and start
sudo systemctl enable --now nginx
Service Status
Check service status
systemctl status nginx
Check if active
systemctl is-active nginx
Check if enabled
systemctl is-enabled nginx
List all services
systemctl list-units --type=service
List running services
systemctl list-units --type=service --state=running
List failed services
systemctl list-units --type=service --state=failed
Service Logs
View service logs
journalctl -u nginx
Follow logs (tail -f)
journalctl -u nginx -f
Last 50 lines
journalctl -u nginx -n 50
Logs since today
journalctl -u nginx --since today
Logs between times
journalctl -u nginx --since "2024-01-01 10:00" --until "2024-01-01 12:00"
Clear journal logs
sudo journalctl --vacuum-time=7d // Keep 7 days
sudo journalctl --vacuum-size=1G // Keep 1GB
System Control
Reboot system
sudo systemctl reboot
Power off system
sudo systemctl poweroff
Suspend system
sudo systemctl suspend
Hibernate system
sudo systemctl hibernate
Reload systemd configuration
sudo systemctl daemon-reload
List all unit files
systemctl list-unit-files
Show service file
systemctl cat nginx