Task 11 — List running systemd services
Submit 11.sh that prints the name of every currently running systemd service unit, one per line.
Submit as
11.sh
Input
| Source | Format |
|---|---|
| CLI | No arguments (script queries the local systemd state) |
| System | systemctl on a Linux host with systemd |
Output
| Stream | Format |
|---|---|
| stdout | One unit name per line (e.g. nginx.service, sshd.service). No header/footer lines. Order not specified. |
| stderr | Not checked |
| Exit code | 0 |
Example
#!/usr/bin/env bash
systemctl list-units --type=service --state=running --no-legend --no-pager \
| awk '{print $1}'
stdout (varies by machine):
cron.service
dbus.service
nginx.service
sshd.service
systemd-journald.service
What the grader checks
Static analysis only (no systemd in the grader container). Your script must contain:
systemctlwithlist-unitsorlist-unit-files--type=service(or.servicein the command)- a filter for running / active (
--state=running,--state=active, etc.)
Partial credit: 2 + 3 + 2 pts for the three checks above.
Test on a real Linux VM to confirm runtime output.
Hints
--no-legend --no-pager— machine-friendly linesawk '{print $1}'— UNIT column only