Enable/disable services for Linux startup
June 23, 2011 13:44:21 Last update: June 23, 2011 13:59:26
- Fedora/Redhat
- List current status (for httpd):
# chkconfig --list httpd
Warning: this works only when one of/etc/rcrunlevel.d/KNNname or/etc/rcrunlevel.d/SNNname exists. It exports wrong status when both K and S scripts exist (in which case the status should be enabled).
- Enable sshd for run levels 2, 3, 5:
# chkconfig --level 2,3,5 sshd on
- Disable sshd for run levels 2, 3, 5:
# chkconfig --level 2,3,5 sshd off
- By default, the
onandoffoptions affect only runlevels 2, 3, 4, and 5.
- List current status (for httpd):
- Debian/Ubuntu
- Add
apache2with defaults:# update-rc.d apache2 defaults
If defaults is used then update-rc.d will make links to start the service in runlevels 2, 3, 4, 5 and to stop the service in runlevels 0, 1, 6.
- Start
apache2for run levels 2, 3, 4, 5 with priority 20, killapache2for run levels 0, 1, 6:# update-rc.d apache2 start 20 2 3 4 5 . stop 80 0 1 6 .
This will create the symbolic links if they don't exist already, otherwise, nothing happens.
- Remove
apache2from all run levels:# update-rc.d -f apache2 remove
The-fswitch forces removal of all symbolic links from therc.xx directories, even if/etc/init.d/name exists. Otherwise, nothing happens when/etc/init.d/name exists.
- Add