1.5 KiB
1.5 KiB
Ubuntu Server 4.2: Listing systemd units
Counting and listing units by state, finding failed services, and masking.
Before you start
Like a server you don't know, this VM has a problem waiting: the lab adds
a service that fails at every boot. It doesn't tell you its name. Write
answers to the files in /root/lab-answers/.
Tasks
- Count the services that are running, and write the number to
/root/lab-answers/1. List the services that are installed but disabled, one per line, in/root/lab-answers/1-disabled. - Write a service whose
ExecStart=points at a program that doesn't exist, start it, and find it the way you would on a server you don't know. You'll find the lab's failed service too: write its name and the status codesystemctl statusshows for it (such as1/FAILURE) to/root/lab-answers/2. Then delete both units, rundaemon-reloadandreset-failed, so thatsystemctl --failedlists0 loaded units. - Mask
apport, then list every masked unit into/root/lab-answers/3. Unmask it afterwards, sosystemctl is-enabled apportprintsenabledagain.
Hints
systemctl list-units --type=service --state=running --no-legend,wc -l;systemctl list-unit-files --type=service --state=disabled.systemctl --failed,systemctl status NAME,systemctl cat NAME,journalctl -u NAME;systemctl reset-failed.systemctl mask,systemctl list-unit-files --state=masked,systemctl unmask.