Verified: tested on WSL2 Ubuntu 24.04 — systemctl status, is-active/is-enabled, service –status-all, and journalctl all passed.
1. TL;DR: pick by scenario
- Interactive single service:
systemctl status <service>, includes process, memory, recent logs. - Script checks for running/enabled:
systemctl is-active/is-enabled, check exit codes. - Batch view of all services:
systemctl list-units --type=serviceorlist-unit-files. - Legacy SysV scripts:
service --status-all, output[ + ]/[ - ]. - Process and logs:
pgrep/psto locate PIDs,journalctl -ufor logs.
2. systemctl status: preferred, with logs
systemctl status cron --no-pager
systemctl status cron --no-pager -l
systemctl status cron --no-pager --lines=20
Sample output:
● cron.service - Regular background program processing daemon
Loaded: loaded (.../cron.service; enabled; preset: enabled)
Active: active (running) since Thu 2026-11-05 00:44:16 CST
Docs: man:cron(8)
Main PID: 159 (cron)
Tasks: 1
Memory: 492.0K
systemctl status reads runtime state from systemd and includes recent journal logs [1]. By default it shows 10 lines and truncates long lines; --full disables truncation, --lines=N sets line count, -l equals --full. The .service suffix can be omitted; systemd completes it.
3. is-active / is-enabled: scripts and checks
systemctl is-active cron; echo "exit=$?"
systemctl is-enabled cron; echo "exit=$?"
systemctl is-failed cron; echo "exit=$?"
is-active: returns 0 if at least one unit is active, non-zero otherwise; prints the state word by default.is-enabled: returns 0 if at least one unit file is enabled; output follows the man page table (enabled/enabled-runtime/masked, etc.).is-failed: checks failed state; pair with--quietto take only the exit code.
Use --quiet in scripts to avoid output noise:
if systemctl is-active --quiet cron; then echo "running"; fi
All three support glob patterns to match multiple units [1].
4. list-units / list-unit-files: batch view
systemctl list-units --type=service --state=running --no-pager --no-legend
systemctl list-units --type=service --state=failed --no-pager
systemctl list-unit-files --type=service --no-pager | grep -i cron
list-units: runtime state of loaded units; add--allto show inactive.list-unit-files: installed unit files and their enablement (enabled/disabled/static/masked).
Both support --type= and --state= filters; list-units shows only active by default, add --all for everything [1].
5. service, ps, pgrep, journalctl: compatibility and process logs
service --status-all
service cron status
pgrep -a cron
ps -o pid,comm,args -C cron
journalctl -u cron --no-pager -n 10
service --status-all: runs status on every init script in alphabetical order;[ + ]running,[ - ]stopped,[ ? ]no status command; only effective for SysV tasks [2].service <name> status: for a systemd unit it delegates to the equivalent systemctl command.pgrep -a/ps -C: locate PIDs by process name, independent of systemd.journalctl -u <service>: logs for that unit, supports--since/--untiltime filters [3].
6. Rollback, troubleshooting, limitations
Troubleshooting quick reference
| Symptom | Cause | Fix |
|---|---|---|
Unit xxx.service could not be found. |
not installed or name typo | systemctl list-unit-files | grep to confirm name |
| status shows inactive (dead) | service not started or exited | systemctl start, then status |
is-enabled outputs masked |
unit masked | systemctl unmask |
service --status-all no output or error |
pure systemd environment, no SysV scripts | use systemctl list-units |
| journalctl cannot read system logs | non-root, not in adm/systemd-journal group | join the group or use sudo |
| process exists but systemctl does not know it | service not registered as a unit | locate with ps/pgrep, or add a unit file |
Limitations
- On WSL2, systemd needs
systemd=truein /etc/wsl.conf; enabled in this environment. service --status-allcovers only SysV tasks; native systemd services are not listed.- Containers often have no systemd;
systemctlerrors out — useps/pgrepor PID files instead. is-failedprints a state word on some versions rather than staying quiet; always add--quietin scripts.
Test record
- Environment: WSL2 Ubuntu 24.04.4 LTS, kernel 6.6.114.1-microsoft-standard-WSL2, systemd running.
systemctl status cron: active (running), Main PID 159, memory 492K.is-active/is-enabled: both returned 0, output active/enabled.service --status-all: cron shown as[ + ].list-unit-files: cron.service is enabled.pgrep -a cron: PID 159, command line /usr/sbin/cron -f -P.journalctl -u cron -n 5: printed startup logs normally.
References
- [1] systemctl(1) – Linux manual page (man7.org) (systemctl(1))
- [2] service(8) — Debian bookworm manual page (service(8))
- [3] journalctl(1) – Linux manual page (man7.org) (journalctl(1))
Main commands above were tested on WSL Ubuntu (24.04) and checked against Debian-family and general distribution docs.