92

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

2 Answers 2

120

Try this command:

sudo update-rc.d -f nginx disable
7
  • 1
    I tried sudo update-rc.d -f nginx disable. What is the difference between them?
    – Alex Malex
    Commented Aug 17, 2012 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
    Commented Aug 17, 2012 at 14:19
  • 1
    I already run disable and then remove. How can I undo it?
    – Alex Malex
    Commented Aug 17, 2012 at 14:32
  • Umm.. You want to enable autostart now?
    – SirCharlo
    Commented Aug 17, 2012 at 14:34
  • 4
    sudo update-rc.d nginx defaults; sudo update-rc.d -f nginx disable
    – SirCharlo
    Commented Aug 17, 2012 at 15:26
63

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

4
  • 3
    it works on ububut 18.04 as well Commented Oct 1, 2019 at 5:10
  • 1
    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. Commented Sep 12, 2020 at 12:26
  • Also works on ububut 20.10 as well Commented Mar 12, 2021 at 18:22
  • 1
    This approach is better.
    – EGurelli
    Commented Oct 13, 2021 at 3:46

You must log in to answer this question.

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