Security and troubleshooting

Diagnose a failed service

Read the manager result, exit status, effective unit, and application messages before editing configuration.

8 minute lesson

~~~

Start with systemctl status, but do not stop at its short log excerpt.

Inspect systemctl show for Result, ExecMainCode, and ExecMainStatus. Read the unit journal and systemctl cat output. Validate the executable and configuration as the service user.

Break a disposable unit with an invalid executable path. Record the exact evidence, repair the path, reload the manager, and confirm the failed state clears.

Collect the service state and the current boot’s logs before restarting:

systemctl status hello.service --no-pager
journalctl -u hello.service -b --no-pager -n 100
systemctl show hello.service -p Result -p ExecMainStatus

Read the first relevant error, not only the final “failed” line. Check the executable, user, working directory, environment, and permissions. If the command works in your shell but fails as a service, run it as the service user with the same working directory and configuration. Change one cause, restart once, then verify the application from outside systemd.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →