Here I will explain different ways of enabling and disabling the system services.
1) Red Hat Method
# chkconfig httpd --add # chkconfig httpd on --level 2,3,5
This will enable the apache webserver to automatically start in the run levels 2, 3 and 5. You can check this by running the command:
# chkconfig --list httpd
One can also disable the service by using the off flag as shown below:
# chkconfig httpd off # chkconfig httpd --del
Red Hat also has a useful script called service which can be used to start or stop any service. Taking the previous example, to start apache webserver, you execute the command:
# service httpd start
and to stop the service…
# service httpd stop
The options being start, stop and restart which are self explanatory.
2) Debian Method
# update-rc.d apache2 defaults
# update-rc.d apache2 start 20 2 3 4 5 . stop 80 0 1 6 .
And to disable the service in all the run levels, you execute the command:
# update-rc.d -f apache2 remove
Here -f option which stands for force is mandatory.
# update-rc.d apache2 start 20 5 . stop 80 0 1 2 3 4 6 .
3) Gentoo Method
# rc-update add apache2 default
… and to remove the webserver, it is as simple as :
# rc-update del apache2
To see all the running applications at your runlevel and their status, similar to what is achieved by chkconfig –list, you use the rc-status command.
# rc-status --all
4) The old fashioned way
# cd /etc/rc5.d/ # ln -s /etc/init.d/apache2 S20apache2
lrwxrwxrwx 1 root root 17 Mar 31 13:02 S20apache2 -> ../init.d/apache2
# ln -s /etc/init.d/apache2 K80apache2
If you have ‘N’ as the priority number for starting a service, you use the number (100-N) for the stopping priority number and vice versa.