2011年1月7日 星期五

Linux Command - chkconfig, service, boot service

If you want to have the NTP server start up automatically, you can use the checkconfig command as follows:

# chkconfig --level 345 ntpd on // In this example, we turn on runlevel 3,4,5 on
# chkconfig --level 0126 ntpd off // In this example, we turn off runlevel 0,1,2,6 off

# chkconfig --list | grep ntpd
ntpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off

// Set vsftpd run on the boot time
# chkconfig vsftpd on
# chkconfig --list vsftpd // list which runlevel the vsftpd was turn on, here the runlevel 2,3,4,5 was turn on automatically
vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off


// Do some experiments on the rc runlevels
# pwd
/etc/rc.d/rc3.d ==> Here we will show the runlevel 3 files

# chkconfig --list xinetd ==> list the xinetd runlevel on/off status
xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off ==> run level 3 was "on"
# ls -la *xin* ==> show the file naming (it is always a linked file with different linked name). Here the name is S56xinetd. we find that the name was start with "S"
lrwxrwxrwx 1 root root 16 2009-11-30 16:11 S56xinetd -> ../init.d/xinetd

# chkconfig --list qemu
qemu 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# ls -la *qemu*
lrwxrwxrwx 1 root root 14 2008-04-16 03:13 S35qemu -> ../init.d/qemu ==> The same as above one. The linked file was started with "S".

# chkconfig --list ypbind
ypbind 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# ls -la *ypbin*
lrwxrwxrwx 1 root root 16 2008-04-16 03:31 K73ypbind -> ../init.d/ypbind ==> This time the ypbind was off. Here the linked file was started with "K".

# chkconfig --list psacct
psacct 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# ls -la *psacct*
lrwxrwxrwx 1 root root 16 2008-04-16 03:13 K10psacct -> ../init.d/psacct ==> The same as above one, the config was off. The linked file was started with "K".


// Again, we set the qemu config as off (before was on), and then the linked file was started with "K" as we think.
# chkconfig qemu off
# chkconfig --list qemu
qemu 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# ls -la *qemu*
lrwxrwxrwx 1 root root 14 2009-12-25 16:30 K98qemu -> ../init.d/qemu


Add a new service into chkconfig maintain list, this will add related symbolic link into /etc/rc.d/ folder
# chkconfig --add tscRC

# find ./* -name *tscRC* -print
./init.d/tscRC
./rc0.d/K92tscRC
./rc1.d/K92tscRC
./rc2.d/S08tscRC
./rc3.d/S08tscRC
./rc4.d/S08tscRC
./rc5.d/S08tscRC
./rc6.d/K92tscRC
# find ./* -name *tscRC* -exec file {} \;
./init.d/tscRC: Bourne shell script text executable
./rc0.d/K92tscRC: symbolic link to `../init.d/tscRC'
./rc1.d/K92tscRC: symbolic link to `../init.d/tscRC'
./rc2.d/S08tscRC: symbolic link to `../init.d/tscRC'
./rc3.d/S08tscRC: symbolic link to `../init.d/tscRC'
./rc4.d/S08tscRC: symbolic link to `../init.d/tscRC'
./rc5.d/S08tscRC: symbolic link to `../init.d/tscRC'
./rc6.d/K92tscRC: symbolic link to `../init.d/tscRC'


If you restart the network service, like following command
# service network restart

All the kernel profile about network settings will be reset to default. So you need to reconfigure those network setting of kernel. For example,

/sbin/sysctl -w net.ipv4.ip_forward=1

GUI service config command to set the boot service
text-mode
# ntsysv

X GUI system
# serviceconf

沒有留言: