I have a CentOS7 server running named-chroot. The problem is named and named-chroot are separate systemd services in CentOS7, and I have both a stable system and a short memory. Months go by between any need for BIND maintenance. When I have BIND work to do, I always forget to type

systemctl restart named-chroot

and instead type

systemctl restart named

If I get it wrong, there's no warning that I'm starting the incorrect service.

I'd like to use systemd configurations to edit the named service to remind me that I've made a mistake. This is as far I've gotten to overriding the standard named service: I use

systemctl edit named

and put in the following:

Description=You want named-chroot

ExecStart=/bin/bash -c "/usr/bin/echo 'No, you want named-chroot'"
ExecReload=/bin/bash -c "/usr/bin/echo 'No, you want named-chroot'"
ExecStop=/bin/bash -c "/usr/bin/echo 'No, you want named-chroot'"

This is as far as I got. The results of the echo commands will be visible in journalctl and systemctl status. Of course, the ideal would be to have them print on the terminal, but I haven't figured that out. This does not work:


nor variants thereof; I get error messages that tell me that /dev/tty is not available in bash!

Another problem: even with the above file, commands like these one can cause named-chroot to halt with no visible indicator or warning:

systemctl restart named
systemctl start named

I can't figure out why the named daemon initiated by named-chroot should be affected by my revised named script, when I've overridden every named service option I could find.

If you're a systemd expert, please help me make this work.


Why don't you just mask the service? This prevents it from starting or being used in any way.

# systemctl mask named
Created symlink /etc/systemd/system/named.service → /dev/null.

# systemctl start named
Failed to start named.service: Unit named.service is masked.
  • Perfect! I didn't know masking was possible. I just tried it, and it worked exactly as you said it would. Thanks! – William Seligman Dec 30 '16 at 16:49

Alternative suggestion. Remove the named unit and create an alias.

Units can be aliased (have an alternative name), by creating a symlink from the new name to the existing name in one of the unit search paths. For example, systemd-networkd.service has the alias dbus-org.freedesktop.network1.service, created during installation as the symlink /usr/lib/systemd/system/dbus-org.freedesktop.network1.service. In addition, unit files may specify aliases through the Alias= directive in the [Install] section; those aliases are only effective when the unit is enabled. When the unit is enabled, symlinks will be created for those names, and removed when the unit is disabled. For example, reboot.target specifies Alias=ctrl-alt-del.target, so when enabled it will be invoked whenever CTRL+ALT+DEL is pressed. Alias names may be used in commands like enable, disable, start, stop, status, …, and in unit dependency directives Wants=, Requires=, Before=, After=, …, with the limitation that aliases specified through Alias= are only effective when the unit is enabled. Aliases cannot be used with the preset command.


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.