I can show you several ways which are documented on this excellent Upstart Cookbook. There are services that can be enabled/disabled using the GUI (Like the
startup application) and then other ways of doing the same through the terminal.
For the Terminal you have several options. Open a terminal (Type "terminal" in the dash for example and open it) and keep on reading:
Enabling / Disabling a service
To toggle a service from starting or stopping permanently you would need to:
echo manual | sudo tee /etc/init/SERVICE.override
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:
echo manual | sudo tee /etc/init/mysql.override
Will put the MySQL service into "manual" mode. If you do not want this, afterwards you can simply do
sudo rm /etc/init/mysql.override
and 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 state of the service "manual".
Temporary enabling/disabling services
To stop and start services temporarily (Does not enable / disable them for future boots), you can type sudo /etc/init.d/SERVICE_NAME. For example:
sudo /etc/init.d/apache2 stop (Will STOP the Apache service until Reboot or until you start it again).
sudo /etc/init.d/apache2 start (Will START the Apache service assuming it was stopped before.).
sudo /etc/init.d/apache2 status (Will tell you the STATUS of the service, if it is either enabled/running of disabled/NOT running.).
sudo /etc/init.d/apache2 restart (Will RESTART the service. This is most commonly used when you have changed, a config file. For example in this case, if you have changed either a PHP configuration or a Apache configuration. Restart will save you from having to stop/start with 2 command lines)
sudo /etc/init.d/apache2 (In this case, since you did not mention the ACTION to execute for the service, so it will show you all options available for that specific service
This of course can vary 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.
IF the service was already converted to Upstart, you should see a message recommending to use the
As you can see it varies in several details when using the
/etc/init.d/SERVICE way. If we would wanted 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 of
restart. It will also tell us if a service was 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.
With upstart with have a simpler way to accessing the service options as you can see in the following examples:
sudo service mysql start (Would START a service)
sudo service mysql stop (Would STOP a service until reboot or start it again)
sudo service mysql restart (Would RESTART the service)
sudo service mysql status (Would show the current STATUS of the service)
But upstart is not limited to only converted services, it can also pass the instructions to non converted services because if offers compatibility with them.
Some shortcuts for the upstart service are:
sudo start mysql
sudo stop mysql
sudo restart mysql
sudo status smbd
There are other commands like initctl which can do nice things like list all services with the status for each of them:
initctl list. It can also start, stop, restart a job as many other options found when you execute
Now, what is the recommended way you ask, for Ubuntu it is Upstart, is an easy to use, easy to manage way to access and work with services, in the present and future of Ubuntu.
Upstart in the future will include options that could replace cron. For example, creating a timed based starting/stopping of services in a very user friendly way. A good guide is found here as the cookbook for upstart: http://upstart.ubuntu.com/cookbook/