RH/CentOS service & chkconfig equivalents in Ubuntu/Debian

9,051

Solution 1

On Debian and Ubuntu you can run /etc/init.d scripts directly, as used to be true also on Red Hat / Centos, or use invoke-rc.d or service. I think the upstart stuff is still evolving, so this may change.

# /etc/init.d/httpd reload
# /usr/bin/service httpd reload
# /usr/sbin/invoke-rc.d httpd reload

update-rc.d is the tool corresponding to chkconfig.

# /usr/sbin/update-rc.d httpd start 20 2 3 4 5 . 80 0 1 6 .

But insserv is becoming the standard way to do this:

 # /sbin/insserv httpd,start=2,3,4,5 # 0,1,6 will be automatically set to off

Solution 2

Services can be started/stopped in Ubuntu with /usr/sbin/service serviceName start|stop. The syntax is the same as RH/Cent, but the path is different. Upstart isn't currently used in Debian, so use /etc/init.d/service serviceName start|stop instead.

/usr/sbin/update-rc.d is what I use to enable/disable services at startup. Check out the manpage for more details.

Share:
9,051

Related videos on Youtube

Alex
Author by

Alex

I'm an iPhone/Cocoa developer.

Updated on September 17, 2022

Comments

  • Alex
    Alex over 1 year

    In RedHat/CentOS distros, you start and stop services with /sbin/service:

    /sbin/service httpd reload
    

    You set whether they should run on startup with /sbin/chkconfig:

    /sbin/chkconfig --levels 2345 on
    

    What are the equivalents for a Debian-based distro like Ubuntu?

  • JeffG
    JeffG about 13 years
    You still can run init.d scripts directly in RedHat/Centos.