Functionally, there is no difference between any of these invocation methods.
start
and stop
are symbolic links to initctl. service
is a shell script that determines whether to execute the init script or use initctl.
The simplest way to see what is an Upstart job is to take a look at /etc/init/
. Everything in there is an Upstart job. If you ls -l /etc/init.d/
you'll see every service and system task. The SysV init jobs will be real files, while the Upstart jobs will be symlinks to /lib/init/upstart-job
which will properly invoke the Upstart job.
In other words, you can also invoke Upstart jobs by calling, for example, /etc/init.d/apport restart
, though the output will suggest using service, start, or stop instead.
So, in practice it makes no difference (yet!). But if I were scripting something, I would certainly use service, start, or stop as there is almost no chance that will deprecated, whereas calling services through /etc/init.d/ could go away down the road (though probably not any time soon).
A note on disabling services: renaming the .conf file works, but I don't recommend it. You might disable a service that way, but if there is a package upgrade available, dpkg will copy down a fresh copy of the Upstart job and without intending it, your service is enabled again. The correct way to disable an Upstart job is to use a .override file which leaves the original job intact.
For example, to disable apport, simply create a file called /etc/init/apport.override
that contains the word "manual".
# echo "manual" > /etc/init/apport.override
Personally, I would avoid using sysv-rc-conf
. It may be safe enough to use it to modify SysV jobs, but I'm not sure; it doesn't seem to support Upstart jobs, and there's no way to tell form the interface which is which. I would stick with update-rc.d
for managing SysV scripts.
For more Upstart information see:
- The Upstart Cookbook: http://upstart.ubuntu.com/cookbook/
- The command
man 5 init
: http://manpages.ubuntu.com/manpages/precise/en/man5/init.5.html
Upstart startup scripts live in /etc/init
, where you can find avahi-daemon.conf
. All things listed in initctl list
match to scripts in /etc/init
, and they are not executable, thus your find
missed them.
To disable a Upstart controlled service, see Upstart cookbook on disabling services: either add #
to start on
line, or use override files (example: sudo sh -c "echo manual > /etc/init/avahi-daemon.override"
).
Best Answer
There are services that can be enabled/disabled using the GUI (like the
startup
application) or the terminal.For the Terminal you have several options. First, open a terminal (Type "terminal" in the dash, for example, and open it). Then:
Temporary enabling/disabling services
To stop and start services temporarily (Does not enable / disable them for future boots), you can type
service SERVICE_NAME [action]
. For example:sudo service apache2 stop
(Will STOP the Apache service until Reboot or until you start it again).sudo service apache2 start
(Will START the Apache service assuming it was stopped before.).service apache2 status
(Will tell you the STATUS of the service, if it is either enabled/running of disabled/NOT running.).sudo service apache2 restart
(Will RESTART the service. This is most commonly used when you have changed, a config file. In this case, if you changed either a PHP configuration or an Apache configuration. Restart will save you from having to stop/start with 2 command lines)service apache2
(In this case, since you did not mention the ACTION to execute for the service, it will show you all options available for that specific service.) This aspect varies depending on the service, for example, with MySQL it would only mention that it is missing a parameter. For other services like networking service it would mention the small list of all options available.SYSTEMD
Starting with Ubuntu 15.04, Upstart will be deprecated in favor of Systemd. With Systemd to manage the services we can do the following (through the
systemctl action SERVICE
pattern):systemctl start SERVICE
- Use it to start a service. Does not persist after rebootsystemctl stop SERVICE
- Use it to stop a service. Does not persist after rebootsystemctl restart SERVICE
- Use it to restart a servicesystemctl reload SERVICE
- If the service supports it, it will reload the config files related to it without interrupting any process that is using the service.systemctl status SERVICE
- Shows the status of a service. Tells whether a service is currently running.systemctl enable SERVICE
- Turns the service on, on the next reboot or on the next start event. It persists after reboot.systemctl disable SERVICE
- Turns the service off on the next reboot or on the next stop event. It persists after reboot.systemctl is-enabled SERVICE
- Check if a service is currently configured to start or not on the next reboot.systemctl is-active SERVICE
- Check if a service is currently active.systemctl show SERVICE
- Show all the information about the service.sudo systemctl mask SERVICE
- Completely disable a service by linking it to/dev/null
; you cannot start the service manually or enable the service.sudo systemctl unmask SERVICE
- Removes the link to/dev/null
and restores the ability to enable and or manually start the service.UPSTART (Deprecated Since 15.04)
If we want to use the official Upstart way (Note that, for the moment, not all services have been converted to Upstart), we could use the following commands:
status SERVICE
- This will tell us if a converted service is running or not. Note that this is deprecated in favor ofstart
,stop
,status
&restart
. It will also tell us if a service has not yet been converted to upstart:A converted service would typically output the current status (Starting, Running, Stopping...) and process ID. A non converted service would give an error about an unknown job.
Some shortcuts may only work with the
service
command above but not with the commands below unless they are 100% converted to upstart services:START -
sudo start mysql
STOP -
sudo stop mysql
RESTART -
sudo restart mysql
STATUS -
sudo status smbd
Enabling / Disabling a service
To toggle a service from starting or stopping permanently you would need to:
where the stanza
manual
will stop Upstart from automatically loading the service on next boot. Any service with the.override
ending will take precedence over the original service file. You will only be able to start the service manually afterwards. If you do not want this then simply delete the.override
. For example:Will put the MySQL service into
manual
mode. If you do not want this, afterwards you can simply doand Reboot for the service to start automatically again. Of course to enable a service, the most common way is by installing it. If you install Apache, Nginx, MySQL or others, they automatically start upon finishing installation and will start every time the computer boots. Disabling, as mentioned above, will make use of the service
manual
.