Wednesday, June 2, 2010

CHKCONFIG on Ubuntu sysv-rc-conf

SkyHi @ Wednesday, June 02, 2010
Ubuntu has got it's own tools for telling the system which services to automatically start at the different run levels, none of them unfortunately is chkconfig which happens to be my favourite tool on Red Hat derivative distributions if you are like me and like using what you are used to by typing the following into your bash shell you can use chkconfig instead of the Ubuntu tools.

$ apt-get install libnewt0.52
$ ln -s /usr/lib/libnewt.so.0.52 /usr/lib/libnewt.so.0.50
$ wget http://www.tuxx-home.at/projects/chkconfig-for-debian/chkconfig_1.2.24d-1_i386.deb
$ dpkg --force-all -i chkconfig_1.2.24d-1_i386.deb

usage of chkconfig is as follows

chkconfig --level 0123456 program_name on
will turn on program_name so that it starts up on all runlevels, this is a bad example since you would seldom want an app or service to run on runlevel 0 (shutdown) or run level 6 (reboot)

chkconfig --list

will show you a comprehensive list of all services / programs and what run levels they will start on.

another easy to use tool for editing runlevels is sysv-rc-conf

to install
apt-get install sysv-rc-conf

and then just type sysv-rc-conf
gives a very easy to use interface for managing your runlevel symlinks



Ubuntu now includes chkconfig in the repositories
so now you can simply $sudo apt-get install chkconfig



REFERENCES
http://cgerada.blogspot.com/2008/06/chkconfig-on-ubuntu.html


Red Hat/Debian/Gentoo Startup Commands



Since there are so many similarities and differences between Linux distributions, I put together this quick summary of the differences between the startup commands on a few of the popular distros (Red Hat, Debian/Ubuntu, and Gentoo):


The commands:


Red Hat: chkconfig

Debian: update-rc.d

Gentoo: rc-update


Start on bootup using the defaults:


chkconfig --add foobar

chkconfig foobar on



update-rc.d foobar defaults



rc-update add foobar default


Explicitly setting run levels (the 30/70 below are the sequence numbers):


chkconfig --level 2345 foobar on

chkconfig --level 016 foobar off



update-rc.d foobar start 30 2 3 4 5 . stop 70 0 1 6 .


Disabling/removing a service:


chkconfig foobar off

chkconfig --del foobar



update-rc.d foobar stop 20 2 3 4 5 .

update-rc.d -f foobar remove



rc-update del foobar

On Debian-based systems adding a script to runlevels is accomplished
with the following (assuming you have the script in /etc/init.d):

update-rc.d
-f myservicename start 80 2 3 4 5 . stop 30 0 1 6 .

The
priority (80 for start and 30 for
stop) is set and the runlevels
(starting in 2 3 4 5 and stopping in 0 1 6) in which the script will be
executed.

List current settings (no Debian version):


chkconfig --list foobar



rc-status --all

REFERENCES
http://www.utahsysadmin.com/2007/07/16/red-hatdebiangentoo-startup-commands/