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 use of the service
Temporary enabling/disabling services
To stop and start services temporarily (Does not enable / disable them for future boots), you can type
service SERVICE_NAME. 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.