Update-rc.d Cheat Sheet

Thank to http://www.jamescoyle.net/cheat-sheets/791-update-rc-d-cheat-sheet

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. See my post on runlevels.

What services are available for startup?

Use the status-all switch to list all services which are registered with the OS. The display will also indicate if the service is started during statup.

  • [ + ] – Services with this sign will start at OS boot.
  • [ – ] – Services with this sign do not start at OS boot.

 

1
service –status-all

Sample output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
service –status-all
[ ? ] acpid
[ – ] apparmor
[ ? ] apport
[ ? ] atd
[ – ] bootlogd
[ ? ] console-setup
[ ? ] cron
[ ? ] dbus
[ ? ] dmesg
[ ? ] dns-clean
[ ? ] friendly-recovery
[ ? ] glusterfs-server
[ – ] grub-common
[ ? ] gssd
[ ? ] hostname
[ ? ] hwclock
[ ? ] hwclock-save
[ ? ] idmapd
[ ? ] irqbalance
[ ? ] killprocs
[ ? ] module-init-tools
[ ? ] network-interface
[ ? ] network-interface-container
[ ? ] network-interface-security
[ ? ] networking
[ ? ] ondemand
[ ? ] passwd
[ ? ] plymouth
[ ? ] plymouth-log
[ ? ] plymouth-ready
[ ? ] plymouth-splash
[ ? ] plymouth-stop
[ ? ] plymouth-upstart-bridge
[ ? ] portmap
[ ? ] portmap-wait
[ ? ] pppd-dns
[ ? ] procps
[ ? ] rc.local
[ ? ] resolvconf
[ ? ] rpcbind-boot
[ – ] rsync
[ ? ] rsyslog
[ ? ] screen-cleanup
[ ? ] sendsigs
[ ? ] setvtrgb
[ + ] ssh
[ ? ] statd
[ ? ] statd-mounting
[ – ] stop-bootlogd
[ – ] stop-bootlogd-single
[ ? ] sudo
[ ? ] udev
[ ? ] udev-fallback-graphics
[ ? ] udev-finish
[ ? ] udevmonitor
[ ? ] udevtrigger
[ ? ] ufw
[ ? ] umountfs
[ ? ] umountnfs.sh
[ ? ] umountroot
[ – ] unattended-upgrades
[ – ] urandom
[ ? ] whoopsie

 

Start a service

Starting a service is done using the command service followed by the service name and the command to start the service.

1
service apache2 start

 

Stop a service

Use the stop keyword with service to stop a service.

1
service apache2 stop

 

Check the status of a service

Each service has a status, usually running or not running. Some services, such as network, may have a different output and output more information on the service.

1
service apache2 status

 

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.

1
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.dfile will be added to the relevent rc.d startup folders.

1
 update-rc.d apache2 defaults