Debian and Ubuntu use the service command to control services and update-rc.d for adding and removing services from start up. Using the service command we can start, stop, restart and display all available services. With update-rc.d we can add and remove services and add them to the Ubuntu/ Debian start up scripts. As Linux operating systems have multiple states, or runlevels, you need to make sure you add any new services to the correct runlevels. For example, you would not want to start a web service application before starting networking.
List Avaialble Services
Use the status-all switch to list all services which are registered with the OS and issues them a status command. You will then get one of the following displayed next to each service:
- [ + ] – Services with this sign are currently running.
- [ – ] – Services with this sign are not currently running..
- [ ? ] – Services that do not have a status switch.
Remove a service
Use the remove keyword with update-rc.d to remove the service start up command for an application. You will need to use the -f switch if the applications /etc/init.d start up file exists.
|#update-rc.d -f apache2 remove|
Add a service
Adding a service to Ubuntu or Debian is done with the update-rc.d command. You can specify which runlevels to start and stop the new service or accept the defaults. The init.d file will be added to the relevent rc.d startup folders.
|#update-rc.d apache2 defaults|