« Back to Systemd: Frequently Asked Questions

How to override the settings of a systemd unit

How to override the settings of a systemd unit?

Run systemctl with the 'edit' subcommand followed by the related unit to create an override file.

systemctl edit UNIT

The systemctl command can show settings of a systemd unit, such as a service. It can also assist in overriding these settings by using the edit subcommand followed by the unit name. This will open the editor that is configured on the system and create the override file.

Usage

Run the edit command with the unit, and the editor like vim or nano will show up.

### Editing /etc/systemd/system/nginx.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

[Service]
ProtectSystem=strict
ReadWritePaths=/run /var/log/nginx

### Lines below this comment will be discarded
<snip>

Important: Do not remove the comments and only insert or change between the specified comment lines.

Learn more about systemctl

This article uses the systemctl command to achieve its tasks. For this popular tool there is a cheat sheet available!

» Mastering the tool: systemctl

systemctl cheat sheet

Other questions related to Systemd

    Related articles

    Like to learn more? Here is a list of articles within the same category or having similar tags.

    Feedback

    Small picture of Michael Boelen

    This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

    Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

    Mastodon icon