6

we are install some service on redhat 7

but for now we no need the service application anymore

is it possible to disable the start of the service?

I not mean to disable it on the next reboot what we mean is to avoid starting the service , in spite service installed

2 Answers 2

12

systemctl disable servicename.

Running systemctl disable removes the symlink to the service in /etc/systemd/system/*.

From now on, that service won't start on boot anymore.

1
  • stop service first then disable. In my case service after 'diabled' was still restarting until I restarted PC
    – fider
    Sep 5, 2022 at 14:15
9

There is also a stronger version of the disable command, which is mask. From the manual:

mask UNIT…

Mask one or more units, as specified on the command line. This will link these unit files to /dev/null, making it impossible to start them. This is a stronger version of disable, since it prohibits all kinds of activation of the unit, including enablement and manual activation. Use this option with care. This honors the --runtime option to only mask temporarily until the next reboot of the system. The --now option may be used to ensure that the units are also stopped. This command expects valid unit names only, it does not accept unit file paths.

While systemctl disable unit would prevent a unit from starting on the next boot, you could still start the unit manually. systemctl mask unit prevents the unit from being started either automatically or manually. It does so by overriding the unit file with a symlink to /dev/null.

Finally, the command to reverse the effects of mask is unmask: systemctl unmask unit.

1
  • this is exactly what I need since the service is controlled by puppet which starts it "manually". Jan 14, 2021 at 0:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .