I went through some manuals and I didn't understand yet. How do I disable autostart nginx service?
Asked
Active
Viewed 9.2k times
2 Answers
117
Try this command:
sudo update-rc.d -f nginx disable
SirCharlo
- 39,016
- 10
- 75
- 82
-
1I tried `sudo update-rc.d -f nginx disable`. What is the difference between them? – Alex Malex Aug 17 '12 at 14:15
-
1The 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](http://askubuntu.com/a/63511/40421). – SirCharlo Aug 17 '12 at 14:19
-
1I 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
-
I want to undo remove. And then call disable again if necessary. – Alex Malex Aug 17 '12 at 15:22
-
4`sudo update-rc.d nginx defaults; sudo update-rc.d -f nginx disable` – SirCharlo Aug 17 '12 at 15:26
-
Apparently does not works on Ubunu 20.10. – Fernando Kosh Mar 12 '21 at 18:22
61
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
S.M.Mousavi
- 1,126
- 10
- 14
-
3
-
1If 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
-
-
1