patternbashMajor
systemctl: Managing systemd Services Correctly
Viewed 0 times
systemctlsystemddaemon-reloadserviceenableunit filefailedrestart
linuxsystemd
Error Messages
Problem
Services fail to start, restart loops occur, or changes to unit files have no effect because systemd was not reloaded after editing.
Solution
Use the correct sequence of systemctl commands when creating or modifying services.
# Check service status with full log tail
systemctl status nginx.service
# Start, stop, restart
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
# Reload config without full restart (if supported)
systemctl reload nginx
# Enable at boot
systemctl enable nginx
# Enable and start in one command
systemctl enable --now nginx
# After editing a unit file — MUST reload daemon
systemctl daemon-reload
systemctl restart myapp
# Show all failed services
systemctl --failed
# Mask a service (prevent it from being started)
systemctl mask apache2Why
systemd caches unit files in memory. Editing
/etc/systemd/system/myapp.service has no effect until daemon-reload is called. This is the most common cause of 'my changes aren't taking effect'.Gotchas
- Forgetting
daemon-reloadafter editing unit files is the #1 systemd mistake. restartstops then starts;reloadsends SIGHUP (service must support it).- A unit in
failedstate won't auto-restart untilsystemctl reset-failedis called if StartLimitBurst is exceeded. - User-level units live in ~/.config/systemd/user/ and require
--userflag:systemctl --user start myservice.
Revisions (0)
No revisions yet.