System
systemd
systemctl and systemd commands for service management.
32 commands
Windows
MacOS
Linux
#service-management
#linux
Service Control
Start a service
sudo systemctl start nginx
Stop a service
sudo systemctl stop nginx
Restart a service
sudo systemctl restart nginx
Reload service configuration
sudo systemctl reload nginx
Restart only if already running
sudo systemctl try-restart nginx
Status & Info
Show service status and recent logs
systemctl status nginx
Check if a service is running
systemctl is-active nginx
Check if a service has failed
systemctl is-failed nginx
Show all properties of a service
systemctl show nginx
List all loaded services
systemctl list-units --type=service
List failed services
systemctl list-units --failed
Enable/Disable
Enable service to start at boot
sudo systemctl enable nginx
Disable service from starting at boot
sudo systemctl disable nginx
Check if service is enabled
sudo systemctl is-enabled nginx
Enable and start immediately
sudo systemctl enable --now nginx
Mask a service to prevent starting
sudo systemctl mask nginx
Unmask a previously masked service
sudo systemctl unmask nginx
System Targets
Show default boot target
systemctl get-default
Set default to multi-user
sudo systemctl set-default multi-user.target
Switch to rescue mode
sudo systemctl isolate rescue.target
List all available targets
systemctl list-units --type=target
Journal
Show logs for a specific service
journalctl -u nginx
Show logs since today
journalctl -u nginx --since today
Follow service logs in real time
journalctl -u nginx -f
Show last 50 log entries
journalctl -u nginx -n 50
Timer Units
List all active timer units
systemctl list-timers
List all timers including inactive
systemctl list-timers --all
Start a timer unit
sudo systemctl start mytimer.timer
Check timer status and next run
systemctl status mytimer.timer
Quick Commands
Show the status and recent logs of a service
systemctl status nginx
Restart a running service
sudo systemctl restart nginx
Enable a service to start at boot
sudo systemctl enable nginx