3

Can someone clarify for me difference between "enable" and "activate" for systemd unit. There are told, if unit has [Install] section than enable should be called, otherwise just activate is enough.

How this handled in startup process? Systemd automagically makes right decision?

  • Systemd/systemctl does not have an activate command, do you mean start? – Wieland Aug 9 '16 at 10:54
  • Yeap, start - for activate. – Constantine Aug 9 '16 at 11:01
4

To start (activate) a service , you will run the command systemctl start my_service.service, this will start the service immediately in the current session.

To enable a service at boot , you will run systemctl enable my_service.service .

Enable one or more units or unit instances. This will create a set of symlinks, as encoded in the "[Install]" sections of the indicated unit files. After the symlinks have been created, the system manager configuration is reloaded (in a way equivalent to daemon-reload), in order to ensure the changes are taken into account immediately

The /usr/lib/systemd/system/ contains init scripts , when you type systemctl enable to start a service at boot it will be linked to /etc/systemd/system/.

#systemctl enable my_service.service
ln -s '/usr/lib/systemd/system/my_service.service' '/etc/systemd/system/multi-user.target.wants/my_service.service'
  • 1
    under "init scripts" you mean unit files ? – Constantine Aug 9 '16 at 16:52
3

systemctl enable configures the system to start the service at next reboot (with caveats around correct target states, etc).

systemctl start starts (activates) the service immediately.

So if you want a service to start now and on every reboot then you need to both enable and start the service.

  • 3
    The last sentence is not true: systemctl enable --now will both start and enable a unit. – Wieland Aug 9 '16 at 12:07

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.