The systemd blog contains two articles that advice against using /etc/sysconfig or /etc/default:

What alternatives are there to configure system specific options for a systemd unit file?

Options I've considered:

  • create a template unit instead and use a specifier

The downside is that you need to specify the option every time the service is started. This is mainly useful to run multiple copies of a single service so it is not really applicable.

  • override the Execstart of the unit file locally with a unitd.d directory

The disadvantage here is that this requires to override the entire Execstart. It cannot be used to simply specify a single option.


It depends a little on what option you're trying to configure. If it's a folder location (like the home directory, runtime directory, etc.), systemd provides this through variables.

Otherwise, you can use an environment file to specify the options, and then have the service unit include the variables in those files. For example, the service file would contain the following (in addition to the usual parameters):

Environment=ENV_OPTION_1=0 ENV_OPTION_2=linux
ExecStart=/usr/bin/program $ENV_OPTION_1 ${ENV_OPTION_2}

EnvironmentFile points to a simple file that contains key-value pairs, like so:


Environment are default options you may want to have.

The environment values are then used in ExecStart as shown above. Note that if the value may be space-separated, you need to use the ${} syntax.

| improve this answer | |
  • 1
    The posts I refer to explicitely suggest to avoid using files in /etc/sysconfig or /etc/default. The EnvironmentFile option as used here is what I am using now and what e.g. sshd is using but which should be avoided if you want to adher to systemd "guidelines". Only those guidelines do not clearly state what alternative to use. Which is what I am looking for with this question. – Bram Feb 23 '16 at 20:09

As I have said elsewhere (q.v.), the systemd people want you to use the snippet .conf files, and consider EnvironmentFile to be a bad idea and its use a mistake.

You can even have multiple snippet files:

# wibble.service.d/execstart.conf
ExecStart=/usr/local/bin/wibble $OPTIONS0 $OPTIONS1
# wibble.service.d/options0.conf
# wibble.service.d/options1.conf

Further reading

| improve this answer | |
  • It's possible to "override" the systemd unit file by adding further configuration, and the unit files are merged together. Can you expand on that idea? – CMCDragonkai Dec 20 '19 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.