I can show you several ways. There are services that can be enable/disable using the GUI (Like Gnome) and then other ways of doing the the same through the terminal. Since we are talking about Ubuntu and Ubuntu is quickly moving to Upstart (At least most is in Upstart job format) I will mention the way to do it via Upstart.
At least this way, for future versions it will still work. For a more permanent solution to enabling/disabling a service, see the end of this answer:
UBUNTU (Classic Gnome / Fallback) GUI WAY
System -> Preferences -> Startup Applications
Here you can click and enable/disable SOME of the services that start from a Desktop Ubuntu. Simply click on one to Enable/Disable. Note that not all services appear here, commonly only the ones that involve a system tray icon or GUI windows. Examples like the HP System Tray and the Nvidia Settings.
- Open the Dash and type
startup app, you should see one option:
- Open the Startup Applications App and Enable/Disable any of the services you find there. As in the Classic Gnome/Fallback way, it will only show services related to the GUI. For example:
For the Terminal you have several options. Open a terminal (Type
terminal in the dash for example) and keep on reading:
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). You should see something similar to the following:
sudo /etc/init.d/apache2 start (Will START the Apache service assuming it was stopped before.). Similar to the following image:
sudo /etc/init.d/apache2 status (Will tell you the STATUS of the service, if it is either enabled/running of disabled/NOT running.). Similar to the following line:
IF the service was already converted to Upstart, you should see a message similar to this one (Which already includes a small help to guide you on how to use the new format):
As you can see, with Apache2 it shows the status format that comes with Apache2. With cups, since it was converted to Upstart, it shows a neat message that explains the change and how to use it.
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, it will show you all options available for that specific service) as seen in the following image:
Note that this is not for all services, for example, here we can see how MySQL would react:
And here how the networking service would output:
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. It will also tell us if a service was not yet been converted to upstart:
A converted service would typically output like the following image:
It would mention the status, either running or stopped and the ID of the process. A not yet converted service would say something like the following image:
With upstart with have a simpler way to accessing the service options as you can see in the following images:
sudo service mysql start (You can START a service)
sudo service mysql stop (You can STOP a service until reboot or start it again)
sudo service mysql restart (You can RESTART the service)
sudo service mysql status (You can even see the STATUS of the service)
But upstart is not limited to this, it can also work with services not yet converted to upstart:
And not only this but it can also get to as small as one command for starting, stopping, restarting or even as mentioned before, looking for the status of a service:
MANUAL SERVICE / (PERMANENT ENABLE/DISABLE)
But all of this is great for temporarily working with the service. How about a way to toggle the service until the user wants to toggle it again. Here is how. Since Upstart 1.3 we can tell a service to only start when we want to:
sudo sh -c "echo 'manual' > /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:
sudo sh -c "echo 'manual' > /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.
NOTE - Even though the Upstart cookbook mentions the manual approach like this:
echo "manual" >> /etc/init/SERVICE.override
If this does not work and throws you a Permission Denied error, you can use it like the one I previously mentioned, with only one ">" (Greater than sign).
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 guid is found here as the cookbook for upstart: http://upstart.ubuntu.com/cookbook/