69

I went through some manuals and I didn't understand yet. How do I disable autostart nginx service?

101

Try this command:

sudo update-rc.d -f nginx disable
6
  • 1
    I tried sudo update-rc.d -f nginx disable. What is the difference between them? – Alex Malex Aug 17 '12 at 14:15
  • 1
    The difference is that disable is better! :) You got me. It effectively 'makes dpkg aware of your preference to prevent the startup scripts from being executed (because dpkg runs update-rc.d too)'. Credit to @Lekensteyn for the explanation. – SirCharlo Aug 17 '12 at 14:19
  • 1
    I already run disable and then remove. How can I undo it? – Alex Malex Aug 17 '12 at 14:32
  • Umm.. You want to enable autostart now? – SirCharlo Aug 17 '12 at 14:34
  • 4
    sudo update-rc.d nginx defaults; sudo update-rc.d -f nginx disable – SirCharlo Aug 17 '12 at 15:26
37

Update:
I made changes to supports more distributions:

use this:

sudo systemctl disable nginx

It will disable it and if you like to stop running service use this:

sudo systemctl stop nginx

works on Ubuntu and any Systemd based distributions

2
  • 2
    it works on ububut 18.04 as well – Amrit Shrestha Oct 1 '19 at 5:10
  • If you're going to use systemd style, use it for everything, don't have some weird mashup of using the service shim for some commands. That second one should just be sudo systemctl stop nginx. – Félix Saparelli Sep 12 '20 at 12:26

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.