If you attempt to use the command “sudo /sbin/service service_name start
” on a Ubuntu computer, the message “/sbin/service: No such file or directory
” will appear. The /sbin/service script is the script used by Red Hat-based Linux distributions to control system services. This script is not found in the same location in the Ubuntu Linux distribution. Instead, Ubuntu has a different method for starting and stopping services.
Services Explained
A service is a program that runs in the background performing essential tasks or waiting to respond to a request. Services are typically started during the boot process and are owned by the root user. Common services include the “apache2,” “mysql,” “cron” and “gdm” services. Services can be started and stopped manually by the system administrator. Typically, they are only stopped or restarted when the administrator makes configuration changes to the service or if it is not functioning properly.
Using /etc/init.d Commands
The traditional way to manage services on Ubuntu is with the “/etc/init.d/service_name” command, where “service_name” is the name of the service that you want to start. The “/etc/init.d” directory is where the scripts that start the services were traditionally located. Since version 6.10, this directory contains scripts which make the replacement service management method backwards compatible.
The syntax for managing services using the “/etc/init.d” method is:
sudo /etc/init.d service_name start|stop|restart
The command “sudo /etc/init.d service_name start” starts the service. The command “sudo /etc/init.d service_name stop” stops the service. The command “sudo /etc/init.d service_name restart” stops, then restarts the service. The command “ls /etc/init.d” produces a list of all the services.
Using the “service” Command
In Ubuntu 6.10, the method for managing services was changed to the “service” command. The syntax is:
sudo service service_name start|stop|restart
The command “sudo service service_name start” starts the service. The command “sudo service service_name stop” stops the service. The command “sudo service service_name restart” stops then restarts the service. The command “service –status-all” is used to show the status of all the services. You do not have to use the “sudo” command to view the services.
Using the Graphical User Interface
The Ubuntu desktop edition provides a GUI for disabling unwanted services. Click on the “System” menu, highlight the “Administration” option and click on “Services” to open the utility. This starts the Services Settings utility. A list of services appears with a check mark next to the enabled services. Click the “Unlock” button and type the administrator password into the text box to make changes to the services. Place a check mark next to any services you want enabled and remove the check mark next to any services you want to disable. Click the “Close” button to save the changes.
Reference
UbuntuBootupHowto
Linux.com: An Introduction to Services, Runlevels and rc.d Scripts; Jan. 11, 2006