Systemd Cheatsheet - systemctl, journalctl & Units
systemd deserves a pass on its own because on modern Linux distributions it unifies four things that people still split across three parallel toolchains: service management, log querying, scheduling and resource limits. Filtering journalctl by unit, by time window and by priority is far more precise than grepping files in /var/log, especially when a service dies immediately after start - combining --since with -p err narrows the output to this boot's errors. This sheet covers service control, status inspection, journal troubleshooting, targets and runlevels, timers, unit configuration and resource control, and failure analysis. Which group to open depends on the symptom: start and stop for the first, "where do the logs live" for the third, "how do I cap CPU and memory" for the sixth. The timer group is the replacement for crontab, and it wins on execution logs, dependency ordering and inspectable failures.
Typical Use Case
For operators and back-end engineers managing long-running services on a Linux server. systemd replaces SysVinit scripts by unifying service state, boot enablement, logs, scheduled tasks and resource limits under one set of commands and one configuration model. Its real value is a fixed troubleshooting path: status for state, journalctl for logs, cat for configuration, daemon-reload to pick up changes. This sheet covers those four steps plus timers and resource limits, which together resolve almost every configuration problem.
Service Management 8
systemctl start nginxsystemctl stop nginxsystemctl restart nginxsystemctl reload nginxsystemctl enable nginxsystemctl disable nginxsystemctl enable --now nginxsystemctl mask nginxStatus 7
systemctl status nginxsystemctl is-enabled nginxsystemctl is-active nginxsystemctl is-failed nginxsystemctl list-units --type=servicesystemctl list-unit-files --type=servicesystemctl list-units --failedjournalctl 8
journalctl -u nginxjournalctl -u nginx -fjournalctl --since "10 min ago" -u nginxjournalctl --since today --until "1 hour ago"journalctl -p err -bjournalctl -u nginx -n 100 --no-pagerjournalctl --disk-usagejournalctl --vacuum-size=100MTargets & Runlevels 6
systemctl get-defaultsystemctl set-default multi-user.targetsystemctl set-default graphical.targetsystemctl isolate multi-user.targetsystemctl rescuesystemctl list-units --type=targetTimers 6
systemctl list-timerssystemctl list-timers --allsystemctl status <timer>systemctl start <timer> && systemctl enable <timer>systemctl cat <timer>journalctl -u <timer>Service Config & Resource Control 6
systemctl cat nginxsystemctl edit nginxsystemctl edit --full nginxsystemctl daemon-reloadsystemctl set-property nginx CPUQuota=50%systemctl set-property nginx MemoryMax=512MTroubleshooting & Analysis 6
systemctl --failedsystemctl reset-failed nginxsystemd-analyze timesystemd-analyze blamesystemd-analyze critical-chain nginxsystemctl daemon-reloadParameter matrix
| Parameter | Effect | Example |
|---|---|---|
enable --now | Enable at boot and start immediately (two things in one step) | systemctl enable --now nginx |
reload vs restart | Graceful reload without dropping connections / restarting the process drops them | systemctl reload nginx |
mask vs disable | Fully disable (cannot be started indirectly) / merely cancel autostart | systemctl mask nginx |
status | View status, recent logs, and PID | systemctl status nginx |
is-active / is-enabled | Script-friendly exit codes: running / enabled | systemctl is-active nginx |
--failed | List all failed services | systemctl --failed |
journalctl -u -f | Filter by unit and follow in real time | journalctl -u nginx -f |
--since / --until | Filter logs by a time window | journalctl --since "10 min ago" -u nginx |
-p err -b | Errors and above since this boot | journalctl -p err -b |
--vacuum-size | Clean logs, keeping only the given size | journalctl --vacuum-size=100M |
list-timers | List timers, replacing crontab -l | systemctl list-timers |
daemon-reload | Reload after editing a unit file (mandatory) | systemctl daemon-reload |
set-property | Limit CPU and memory at runtime | systemctl set-property nginx MemoryMax=512M |
systemd-analyze blame | List each service startup time sorted by duration | systemd-analyze blame |
Common pitfalls
SymptomAfter editing the unit file, the config still does not take effect after systemctl restart.
Causesystemd does not automatically reload configuration after a unit file is modified.
FixRun systemctl daemon-reload then restart; the same applies to override.conf created by systemctl edit.
SymptomThe service repeatedly fails to start, and status shows a Restarting loop.
CauseThe ExecStart path does not exist, permissions are insufficient, or a dependency is not ready; systemd retries per the Restart policy.
FixCheck the real error with journalctl -u <service> -n 100 --no-pager; verify the ExecStart path with systemctl cat.
SymptomThe service is already enabled, yet it does not start after a machine reboot.
Causeenable only writes the autostart link, but the service was masked, and mask takes precedence over enable.
FixConfirm the real state with systemctl is-enabled <service>; if it is masked, run systemctl unmask first.
SymptomAfter a restart all client connections drop and the service shows a momentary error.
Causerestart kills the old process before starting a new one, dropping all established connections.
FixFor services that support reload (nginx), use systemctl reload for a graceful reload without dropping connections.
SymptomThe disk is filled up by journal logs.
Causejournal rotates by default but the cap can be large, and it is left uncleaned for a long time.
FixCheck usage with journalctl --disk-usage and clean with journalctl --vacuum-size=100M; you can also configure SystemMaxUse.
SymptomStartup got slow and journalctl reports a startup timeout.
CauseSome service unit has an overly long TimeoutStartSec, stalling overall startup when a dependency is slow.
FixFind the slowest units with systemd-analyze blame, inspect the dependency chain with systemd-analyze critical-chain, then address it specifically.
SymptomAfter manually stopping the service, it gets pulled back up by another service a while later.
CauseThe service is started as a dependency by another unit (such as a target or a Requires dependency).
FixCheck reverse dependencies with systemctl list-units --type=service; when you truly want it disabled, use systemctl mask.
Troubleshooting
1The standard four steps when a service is not working
systemctl status nginx && journalctl -u nginx -n 100 --no-pagerstatus shows the state and recent logs, journalctl pulls the full history; these two steps resolve most startup failures.
2Confirm whether the config is actually being read
systemctl cat nginxLists both the main unit file and override fragments, essential when troubleshooting overridden config.
3Make the config take effect after editing the unit file
systemctl daemon-reload && systemctl restart nginxForgetting daemon-reload is the most common cause of "edited but nothing happened."
4Watch the log in real time while tweaking the config
journalctl -u nginx -fOpen another terminal, edit the config and reload; whether the error disappears is immediately visible.
5Check service state in a script
systemctl is-active nginx || systemctl restart nginxis-active expresses state via exit code, ideal for health-check scripts.
Command Examples
Status plus recent logs when a service will not start
systemctl status nginxstatus prints the load state, run state, startup time, and main process, the first step in troubleshooting. To follow real-time logs, add -f to the same command or switch to journalctl -u nginx -f.
Output
● nginx.service - A high performance web server Loaded: loaded (/lib/systemd/system/nginx.service; enabled) Active: active (running) since Mon 2026-09-29 10:12:03 CST; 2 days ago Process: 1420 ExecStart=/usr/sbin/nginx /etc/nginx/nginx.conf
Errors from the last 10 minutes only
journalctl -p err --since "10 min ago" -u nginx --no-pager--since accepts relative times; "10 min ago" saves effort versus an absolute time. Add --no-pager to keep output from going into less and hanging in a script.
Output
Sep 30 14:02:11 host nginx[1420]: [error] 1420#1420: *3 open() "/usr/share/nginx/html/x" failed (2: No such file or directory) Sep 30 14:02:11 host nginx[1420]: [error] 1420#1420: *3 connect() failed (111: Connection refused)
Find out why a service starts slowly
systemd-analyze blame | headblame sorts services by duration; critical-chain <unit> expands a dependency chain. When optimizing startup time, look at the top few first.
Output
1.204s NetworkManager-wait-online.service 842ms docker.service 231ms nginx.service 118ms systemd-logind.service
Common Pitfalls
- Editing a unit file without systemctl daemon-reload leaves systemd using the in-memory version, so nothing changes.
- restart drops connections; prefer reload for a smooth switch, though not every service implements it.
- enable only configures boot-time start and start only affects the current session; use enable --now for both.
- systemctl edit writes an override.conf on top of the original — roll back by deleting that override.
- Non-critical services are stopped in rescue or isolate targets; confirm which target you are in before running this on production.
Tips
- reload gracefully reloads config without dropping connections, while restart recreates the process. Not all services support reload — nginx does.
- journal logs rotate by default; if --disk-usage is too large, clean up with journalctl --vacuum-size=100M.
- Timers are more controllable than crontab: you can see execution logs in journalctl and they support dependency relationships.
- You must run systemctl daemon-reload after editing a unit file, otherwise systemd won't read the new config.
- systemctl edit creates an override.conf snippet that doesn't modify the original unit file — safer.
- mask is more thorough than disable: a masked service cannot be started manually or indirectly. Mask it before uninstalling a service.
FAQ
What is the difference between systemctl start and enable?
start only launches the service in the current session and it will not come back after a reboot; enable configures it to start at boot but does not start it now. They are independent, which is why systemctl enable --now nginx is the idiom for both. To check state, use systemctl is-enabled nginx and systemctl is-active nginx.
When can I not swap restart for reload?
reload applies new configuration without dropping existing connections and suits services like Nginx that support hot reloading; restart interrupts connections and starts over. Use restart only when the unit does not implement reload, or the change touches something that cannot be hot-swapped such as a listening port. Also note a syntax error will simply prevent the service from starting on restart — for Nginx, validate with nginx -t first.
Where do I look when a service will not start?
systemctl status nginx prints the state plus the last few log lines and is the one you will use most; journalctl -u nginx gives the full history and -f follows it live. Bound the window with journalctl --since "10 min ago" -u nginx, or restrict to error level and up with journalctl -p err -b. For a service that keeps restarting, systemctl show nginx explains why it exited.
Why does my systemd unit file change have no effect?
You must run systemctl daemon-reload so systemd re-reads configuration, then restart the service. Editing the file alone leaves systemd using the in-memory version. Prefer systemctl edit nginx for changes — it writes an override.conf instead of touching the original, so rolling back just means deleting that override.
How do I replace crontab with systemd timers?
Use a systemd timer — better suited when you need precise control, want the task to depend on service state, or want logs. systemctl list-timers shows every timer and its next run; after writing a matching .service and .timer pair, enable it with systemctl enable --now <timer>. Output goes to journalctl -u <service>, which is far easier to debug than cron mail.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us