Enable/disable services for Linux startup 

Joined:
04/19/2010
Posts:
94

June 23, 2011 13:44:21    Last update: June 23, 2011 13:59:26
  1. 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 on and off options affect only runlevels 2, 3, 4, and 5.

  2. Debian/Ubuntu
    • Add apache2 with 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 apache2 for run levels 2, 3, 4, 5 with priority 20, kill apache2 for 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 apache2 from all run levels:
      # update-rc.d -f apache2 remove
      

      The -f switch forces removal of all symbolic links from the rc.xx directories, even if /etc/init.d/name exists. Otherwise, nothing happens when /etc/init.d/name exists.

Share |
| Comment  | Tags