ubuntu linux

In Ubuntu we have services that we can enable and disable using Graphical User Interface ( GUI ), for example through the Startup Application, you can find it by searching for “Startup”.

Other way to enable and disable services is through the terminal. To enable and disable services through terminal you have to open the terminal by searching for “terminal” or by using the shortcut Ctrl + Alt + T.

Enable and Disable Services in Ubuntu

To stop a service permanently from starting or stopping you will have to use the ‘manual‘ attribute, for example:

echo manual | sudo tee /etc/init/SERVICE.override

Where ‘manual‘ will stop Upstart from automatically loading the service on the next boot. Also if the service has the .override at the end, it will take control other the original service file and you will not be able to start the service manually afterwards. So you can just simply delete the .override.

For example:

echo manual | sudo tee /etc/init/mysql.override

The command will put the MySQL service into manual mode. To remove manual afterwards you can simple use the following command:

sudo rm /etc/init/mysql.override

Then you have to reboot the service.

Temporary Enable and Disable Services

To stop and start a service temporarily you can use the command attribute ‘service‘.

For example:

sudo service apache2 stop  (Will STOP the Apache service until Reboot).

sudo service apache2 start  (Will START the Apache service, if you stopped it before).

service apache2 status  (Will tell the current STATUS of the service, if it is enabled or disabled, or if it is running or not).

sudo service apache2 restart  (Will RESTART the service, it means that it will stop it then start it).

Read more about restarting the Apache2 web server on this page.

Starting and Stopping Services with UPSTART

To stop and start services you can do it with the Upstart way. Note that for the moment not all services can be started and stopping using the UPSTART way.

You can use the following commands:

sudo status SERVICE (This command will tell us if the service is running or not, also it will tell if a service was or not yet converted to upstart).

sudo start SERVICE (will START the service).

sudo stop SERVICE (will STOP the service).

sudo restart SERVICE (will STOP and then START the service).

Starting and Stopping Services with SYSTEMD

Starting with Ubuntu 15.04, Upstart will be deprecated in favor of Systemd. To start, stop and to do other things with Systemd you can use the following commands:

systemctl start SERVICE.service (Will START a service).

systemctl stop SERVICE.service (Will STOP a service).

systemctl restart SERVICE.service (Will STOP and START a service).

systemctl reload SERVICE.service (Some services support to reload the config files without interrupting the process that is using the service).

systemctl status SERVICE.service (Will show the STATUS of the service currently running).

systemctl enable SERVICE.service (Will TURN ON the service, on the next reboot or next event start).

systemctl disable SERVICE.service (Will TURN OFF the service on the next reboot or stop event).

systemctl is-enabled SERVICE.service (Will CHECK if a service is currently configured to start or not on the next reboot).

systemctl is-active SERVICE.service (Will CHECK if the service is currently active).

systemctl show SERVICE.service (Will SHOW all the information about the service).

Leave a Reply