Is there a systemd system wide config file that is applied to all services

In systemd is there a mechanism or a configuration file which will set defaults for the systemd execution environment configuration for ALL services? Including user created ones.

For example if we want to have all systemd services use specific values for RestrictAddressFamilies or Personality or PrivateTmp then right now we have to go and modify each and every service file. That is hardly optimal. But if there is a configuration file or some setting somewhere maintained so that all systemd services use the the configuration/setting thus maintained then that would be great.

You could create the directory /etc/systemd/system/service.d and drop in a file in there (.conf) with your configuration options.

You can use top-level drop-in files to affect all units of the same type. For example, a drop-in file in /etc/systemd/system/service.d/ affects all .service units.

ref. https://wiki.archlinux.org/title/Systemd#Drop-in_files

For the user created services, I guess you could do the same in ~/.config/systemd/user.

1 Like