Course contentsShow
← Linux
Lesson 616 of 1,8196. Systemd Internals and Unit OrchestrationFree lesson

The Systemd-Analyze Verify Tool

Validate custom unit file syntax and dependency logic before deployment.

In this lesson, you will learn how to use systemd-analyze verify to catch configuration errors and dependency loops in your unit files before you ever attempt to start them.

Why Verification Matters

When you create a custom unit file, it is easy to make a small syntax error—like a typo in an option name—or a logic error, such as creating a circular dependency where Unit A waits for Unit B, but Unit B is waiting for Unit A. Normally, you wouldn't find these mistakes until you run systemctl start, which might leave your system in an unstable state.

The systemd-analyze verify tool performs a "dry run" analysis of your configuration. It parses your unit files, resolves their paths, and checks that every requirement listed in Requires= or Wants= actually exists and is valid.

Using the Tool

To verify a specific unit file you are currently working on, you can simply point the tool to the file path:

systemd-analyze verify /etc/systemd/system/my-custom-service.service

If everything is correct, the command will remain silent and return a zero exit code. If there is a problem, it will output clear error messages to your terminal. For example, if you accidentally typed ExecStartt instead of ExecStart, or if a Requires= directive points to a non-existent target, the tool will flag the exact line number and the nature of the error.

Advanced Dependency Checking

Beyond basic syntax, this tool is excellent for debugging complex service relationships. Because it reads the entire dependency tree, it can detect "dependency cycles." If you define a chain of services that contradicts itself, the tool will warn you immediately.

You can also run it against the entire active configuration to ensure your system’s integrity:

systemd-analyze verify /etc/systemd/system/*.service

By making this command a part of your workflow—running it immediately after saving a file and before calling systemctl daemon-reload—you ensure that your orchestration logic is sound and your services are ready for production.

Key Takeaway: Always run systemd-analyze verify on your unit files to catch syntax errors and dependency loops before they cause runtime failures.