Debian初学者笔记(2)
作者:sealinger 发布时间:October 25, 2010 分类:混口饭吃
2010年02月19日
Debian初学者笔记(2)
1、服务管理工具
1) rcconf :
Debian也有个类似 RedHat 下 ntsysv 的工具,叫 rcconf 。
sealinger:~# apt-cache search rcconf
rcconf – Debian Runlevel configuration tool
sealinger:~# apt-get install rcconf
安装完成后,直接运行即可:
sealinger:~# rcconf
字符界面,类似 ntsysv 的。
2)sysv-rc-conf :
类似 RedHat 下的 chkconfig 命令行工具。
sealinger:~# apt-cache search sysv-rc-conf
sysv-rc-conf – SysV init runlevel configuration tool for the terminal
sealinger:~#apt-get install sysv-rc-conf
The following NEW packages will be installed:
libcurses-perl libcurses-ui-perl sysv-rc-conf
sealinger:~# sysv-rc-conf –list
apache2 0:off 1:off 2:off 3:off 4:off 5:off 6:off
sealinger:~# sysv-rc-conf apache2 onsealinger:~# sysv-rc-conf –list apache2
apache2 0:off 1:off 2:on 3:on 4:on 5:on 6:off
3) chkconfig :
也有跟 RedHat 和 Mandriva 一样的chkconfig工具(不过有瑕疵):
sealinger:~# dpkg -l |grep chkconfigsealinger:~# apt-cache search chkconfig
chkconfig – system tool to enable or disable system services
sealinger:~# apt-get install chkconfig
The following NEW packages will be installed:
chkconfig insserv
不过经试用有点问题,毕竟不是原生的,还是用 sysv-rc-conf 的好。
sealinger:~# chkconfig apache2
apache2 off
sealinger:~# chkconfig apache2 on //命令没有生效:
insserv: warning: script is corrupt or invalid: /etc/init.d/../rc6.d/S00vzreboot
我还是把它卸载了:
sealinger:~# apt-get autoremove chkconfig
The following packages were automatically installed and are no longer required:
insserv
The following packages will be REMOVED:
chkconfig insserv
PS:相比remove,autoremove参数会连同不需要的依赖包一起卸载。
2、添加一个服务 update-rc.d
类似 RedHat 的 chkconfig –add 方式。
比如你已经将一个nginx的启动脚本放在了 /etc/init.d/ 下:
sealinger:/etc/init.d# mv nginxctl nginxsealinger:/etc/init.d# update-rc.d -h
usage: update-rc.d [-n] [-f] <basename> remove
update-rc.d [-n] <basename> defaults [NN | SS KK]
update-rc.d [-n] <basename> start|stop NN runlvl [runlvl] [...] .
-n: not really
-f: force
sealinger:/etc/init.d# update-rc.d nginx defaults
Adding system startup for /etc/init.d/nginx …
/etc/rc0.d/K20nginx -> ../init.d/nginx
/etc/rc1.d/K20nginx -> ../init.d/nginx
/etc/rc6.d/K20nginx -> ../init.d/nginx
/etc/rc2.d/S20nginx -> ../init.d/nginx
/etc/rc3.d/S20nginx -> ../init.d/nginx
/etc/rc4.d/S20nginx -> ../init.d/nginx
/etc/rc5.d/S20nginx -> ../init.d/nginx

