VOOZH about

URL: https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files?comment=63616

⇱ Understanding Systemd Units and Unit Files | DigitalOcean


👁 Understanding Systemd Units and Unit Files

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Former Senior Technical Writer at DigitalOcean, specializing in DevOps topics across multiple Linux distributions, including Ubuntu 18.04, 20.04, 22.04, as well as Debian 10 and 11.

👁 Vinayak Baranwal
Vinayak Baranwal
Editor
Technical Writer II
See author profile

Building future-ready infrastructure with Linux, Cloud, and DevOps. Full Stack Developer & System Administrator. Technical Writer @ DigitalOcean | GitHub Contributor | Passionate about Docker, PostgreSQL, and Open Source | Exploring NLP & AI-TensorFlow | Nailed over 50+ deployments across production environments.

Still looking for an answer?

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Your article is the best I have read on the subject. The only addition I see would be about the ‘systemctl show unitFile’ that displays all the configuration details about a unit file.

hi! nice article! Is it possible to make a .service to wait a HDD gets fully mounted before exec it? Today I add a sleep in pre start unit. I don’t use fstab. My O.S auto-mounts the HDD. I didn’t set anything. Tried add the media-HDD.mount in “After” but didn’t work. thanks!

Thanks for your article!

These tutorials are well written and super helpful. Thanks a lot!

Great article.

Formatting nitpick: in Types of Units, .service is missing a bullet.

The following locations should also be known for .service files:

Runtime

  • Runtime units: $XDG_RUNTIME_DIR/systemd/user

User (when using “systemctl --user”)

  • User Unit Files: $XDG_CONFIG_HOME/systemd/user
  • User Unit Files (when $XDG_CONFIG_HOME is not set): $HOME/.config/systemd/user

Override

  • Override Unit File Load Path: $SYSTEMD_UNIT_PATH

Reference: https://unix.stackexchange.com/a/367237

Very informative and deep article. Thanks.

Maybe it could be interesting to add something about how to run operations on services status, exploring also commands like systemd-delta and systemctl daemon-reload.

And maybe some real example at the end and some picture to have a fast re-read of the article, like for the unit files hierarchy :)

Best Regards

You left out %j, the part of %p after the last hyphen (if there is one, otherwise it is equal to %p). And %J of course.

I think it sad that systemd doesn’t have any string utilities to manipulate %I. E.g. if you pass two arguments as instance: “arg1 arg2” then there is no way to add a rule: After: foo@arg1.service because the only way to get to arg1 is with scripting (aka, as part of a ExecStart). And because of that, there is the question of how to mimic all of the other rules (like Wants:, Requires:, After: etc) with an ExecStart:

👁 Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

© 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.