Ntsysvredhat 提供的集中管理系统各种服务的工具,在RedHat各个发行版,centos各个版本,都自带这个工具。比起solaris 10SMF来,要方便很多了,因为ntsysv一次就可以选中或取消多个服务,而svcadmin只能一个一个的来。
 
RedHat2种方法启用ntsysv:一种是直接在命令行下执行命令 ntsysv,另外一种是执行setup命令间接进入。不管是哪种方式进入,其结果都是相同的。下面用图示来说明一下这个过程。
ntsysv工具_休闲
回车后出现下列菜单:
ntsysv工具_职场_02
光标定位System services ,再按“Tab”键选“Run Tool”,也可以直接回车。
ntsysv工具_linux,linux知识_03
用空白键(最长的那个)选中或取消服务。选中时,服务的前面的方括号里是“*”,反之则表示取消。设置完毕后,按“Tab”到“ok”回车结束配置。如果直接执行命令ntsysv,步骤就比setup少。
 
 
当我们使用ntsysv管理服务时,究竟后面进行的实质是什么?进入当前运行目录/etc/rc3.d(我的系统当前运行级别是3,运行命令 who –r查看之),用命令 ll 列出所有的目录,然后统计一下目录/文件数目:
[root@myest rc3.d]# ll
total 4
lrwxrwxrwx  1 root root 21 Oct 18 12:17 K01tog-pegasus -> ../init.d/tog-pegasus
lrwxrwxrwx  1 root root 13 Oct 18 12:17 K01yum -> ../init.d/yum
lrwxrwxrwx  1 root root 19 Oct 18 12:17 K02haldaemon -> ../init.d/haldaemon
lrwxrwxrwx  1 root root 24 Oct 18 12:17 K02NetworkManager -> ../init.d/NetworkManager
lrwxrwxrwx  1 root root 20 Oct 18 12:17 K03messagebus -> ../init.d/messagebus
lrwxrwxrwx  1 root root 15 Oct 18 12:17 K03rhnsd -> ../init.d/rhnsd
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K05anacron -> ../init.d/anacron
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K10cups -> ../init.d/cups
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K10psacct -> ../init.d/psacct
lrwxrwxrwx  1 root root 13 Oct 18 12:17 K10xfs -> ../init.d/xfs
lrwxrwxrwx  1 root root 13 Oct 18 12:17 K15gpm -> ../init.d/gpm
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K17iiim -> ../init.d/iiim
lrwxrwxrwx  1 root root 13 Oct 18 12:17 K20nfs -> ../init.d/nfs
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K24irda -> ../init.d/irda
lrwxrwxrwx  1 root root 22 Oct 18 12:17 K30courier-imap -> ../init.d/courier-imap
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K35winbind -> ../init.d/winbind
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K40smartd -> ../init.d/smartd
lrwxrwxrwx  1 root root 20 Oct 18 12:17 K44rawdevices -> ../init.d/rawdevices
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K50ibmasm -> ../init.d/ibmasm
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K50netdump -> ../init.d/netdump
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K50xinetd -> ../init.d/xinetd
lrwxrwxrwx  1 root root 15 Oct 18 12:17 K56acpid -> ../init.d/acpid
lrwxrwxrwx  1 root root 19 Oct 18 12:17 K68rpcidmapd -> ../init.d/rpcidmapd
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K69rpcgssd -> ../init.d/rpcgssd
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K72autofs -> ../init.d/autofs
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K73ypbind -> ../init.d/ypbind
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K74apmd -> ../init.d/apmd
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K74nscd -> ../init.d/nscd
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K74ntpd -> ../init.d/ntpd
lrwxrwxrwx  1 root root 15 Oct 18 12:17 K75netfs -> ../init.d/netfs
lrwxrwxrwx  1 root root 25 Oct 18 12:17 K85courier-authlib -> ../init.d/courier-authlib
lrwxrwxrwx  1 root root 19 Oct 18 12:17 K85mdmonitor -> ../init.d/mdmonitor
lrwxrwxrwx  1 root root 15 Oct 18 12:17 K85mdmpd -> ../init.d/mdmpd
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K86nfslock -> ../init.d/nfslock
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K87auditd -> ../init.d/auditd
lrwxrwxrwx  1 root root 20 Oct 18 12:17 K87irqbalance -> ../init.d/irqbalance
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K87portmap -> ../init.d/portmap
lrwxrwxrwx  1 root root 18 Oct 18 12:17 K89netplugd -> ../init.d/netplugd
lrwxrwxrwx  1 root root 19 Oct 18 12:17 K90bluetooth -> ../init.d/bluetooth
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K91isdn -> ../init.d/isdn
lrwxrwxrwx  1 root root 22 Oct 18 12:17 K92arptables_jf -> ../init.d/arptables_jf
lrwxrwxrwx  1 root root 18 Oct 18 12:17 K92iptables -> ../init.d/iptables
lrwxrwxrwx  1 root root 18 Oct 18 12:17 K94diskdump -> ../init.d/diskdump
lrwxrwxrwx  1 root root 15 Oct 18 12:17 K95kudzu -> ../init.d/kudzu
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K95openibd -> ../init.d/openibd
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K96ipmi -> ../init.d/ipmi
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K96pcmcia -> ../init.d/pcmcia
lrwxrwxrwx  1 root root 18 Oct 18 12:17 K99cpuspeed -> ../init.d/cpuspeed
lrwxrwxrwx  1 root root 23 Oct 18 12:17 K99microcode_ctl -> ../init.d/microcode_ctl
lrwxrwxrwx  1 root root 19 Oct 18 12:17 K99readahead -> ../init.d/readahead
lrwxrwxrwx  1 root root 25 Oct 18 12:17 K99readahead_early -> ../init.d/readahead_early
lrwxrwxrwx  1 root root 17 Oct 18 12:17 S10network -> ../init.d/network
lrwxrwxrwx  1 root root 16 Oct 18 12:17 S12syslog -> ../init.d/syslog
lrwxrwxrwx  1 root root 14 Oct 18 12:17 S55sshd -> ../init.d/sshd
lrwxrwxrwx  1 root root 15 Oct 18 12:17 S90crond -> ../init.d/crond
lrwxrwxrwx  1 root root 13 Oct 18 12:17 S95atd -> ../init.d/atd
lrwxrwxrwx  1 root root 11 Jul 30 13:23 S99local -> ../rc.local
全是链接文件,真实的文件在目录/etc/init.d呢。
[root@myest rc3.d]# ll | wc -l
58
现在/etc/rc3.d目录有58个链接文件。接下来,我们使用ntsysv添加一个服务,如“kuzdu”,执行完毕后,再查目录/etc/rc3.d,其结果如下:
[root@myest rc3.d]# ll                                                        
total 4
lrwxrwxrwx  1 root root 21 Dec 20 14:24 K01tog-pegasus -> ../init.d/tog-pegasus
lrwxrwxrwx  1 root root 13 Dec 20 14:24 K01yum -> ../init.d/yum
lrwxrwxrwx  1 root root 19 Dec 20 14:24 K02haldaemon -> ../init.d/haldaemon
lrwxrwxrwx  1 root root 24 Dec 20 14:24 K02NetworkManager -> ../init.d/NetworkManager
lrwxrwxrwx  1 root root 20 Dec 20 14:24 K03messagebus -> ../init.d/messagebus
lrwxrwxrwx  1 root root 15 Dec 20 14:24 K03rhnsd -> ../init.d/rhnsd
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K05anacron -> ../init.d/anacron
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K10cups -> ../init.d/cups
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K10psacct -> ../init.d/psacct
lrwxrwxrwx  1 root root 13 Dec 20 14:24 K10xfs -> ../init.d/xfs
lrwxrwxrwx  1 root root 13 Dec 20 14:24 K15gpm -> ../init.d/gpm
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K17iiim -> ../init.d/iiim
lrwxrwxrwx  1 root root 13 Dec 20 14:24 K20nfs -> ../init.d/nfs
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K24irda -> ../init.d/irda
lrwxrwxrwx  1 root root 22 Dec 20 14:24 K30courier-imap -> ../init.d/courier-imap
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K35winbind -> ../init.d/winbind
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K40smartd -> ../init.d/smartd
lrwxrwxrwx  1 root root 20 Dec 20 14:24 K44rawdevices -> ../init.d/rawdevices
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K50ibmasm -> ../init.d/ibmasm
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K50netdump -> ../init.d/netdump
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K50xinetd -> ../init.d/xinetd
lrwxrwxrwx  1 root root 15 Dec 20 14:24 K56acpid -> ../init.d/acpid
lrwxrwxrwx  1 root root 19 Dec 20 14:24 K68rpcidmapd -> ../init.d/rpcidmapd
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K69rpcgssd -> ../init.d/rpcgssd
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K72autofs -> ../init.d/autofs
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K73ypbind -> ../init.d/ypbind
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K74apmd -> ../init.d/apmd
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K74nscd -> ../init.d/nscd
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K74ntpd -> ../init.d/ntpd
lrwxrwxrwx  1 root root 15 Dec 20 14:24 K75netfs -> ../init.d/netfs
lrwxrwxrwx  1 root root 25 Dec 20 14:24 K85courier-authlib -> ../init.d/courier-authlib
lrwxrwxrwx  1 root root 19 Dec 20 14:24 K85mdmonitor -> ../init.d/mdmonitor
lrwxrwxrwx  1 root root 15 Dec 20 14:24 K85mdmpd -> ../init.d/mdmpd
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K86nfslock -> ../init.d/nfslock
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K87auditd -> ../init.d/auditd
lrwxrwxrwx  1 root root 20 Dec 20 14:24 K87irqbalance -> ../init.d/irqbalance
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K87portmap -> ../init.d/portmap
lrwxrwxrwx  1 root root 18 Dec 20 14:24 K89netplugd -> ../init.d/netplugd
lrwxrwxrwx  1 root root 19 Dec 20 14:24 K90bluetooth -> ../init.d/bluetooth
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K91isdn -> ../init.d/isdn
lrwxrwxrwx  1 root root 22 Dec 20 14:24 K92arptables_jf -> ../init.d/arptables_jf
lrwxrwxrwx  1 root root 18 Dec 20 14:24 K92iptables -> ../init.d/iptables
lrwxrwxrwx  1 root root 18 Dec 20 14:24 K94diskdump -> ../init.d/diskdump
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K95openibd -> ../init.d/openibd
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K96ipmi -> ../init.d/ipmi
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K96pcmcia -> ../init.d/pcmcia
lrwxrwxrwx  1 root root 18 Dec 20 14:24 K99cpuspeed -> ../init.d/cpuspeed
lrwxrwxrwx  1 root root 23 Dec 20 14:24 K99microcode_ctl -> ../init.d/microcode_ctl
lrwxrwxrwx  1 root root 19 Dec 20 14:24 K99readahead -> ../init.d/readahead
lrwxrwxrwx  1 root root 25 Dec 20 14:24 K99readahead_early -> ../init.d/readahead_early
lrwxrwxrwx  1 root root 15 Dec 20 14:24 S05kudzu -> ../init.d/kudzu
lrwxrwxrwx  1 root root 17 Dec 20 14:24 S10network -> ../init.d/network
lrwxrwxrwx  1 root root 16 Dec 20 14:24 S12syslog -> ../init.d/syslog
lrwxrwxrwx  1 root root 14 Dec 20 14:24 S55sshd -> ../init.d/sshd
lrwxrwxrwx  1 root root 15 Dec 20 14:24 S90crond -> ../init.d/crond
lrwxrwxrwx  1 root root 13 Dec 20 14:24 S95atd -> ../init.d/atd
lrwxrwxrwx  1 root root 11 Jul 30 13:23 S99local -> ../rc.local
从输出可以看见多了一个文件 S05kudzu,文件个数现在是59,确实是多了一个。再运行工具ntsysv把这个服务取消,这时目录/etc/rc3.d将删除链接文件S05kuzdu。由此我们可以得出结论,ntsysv的作用就是把目录/etc/init.d的文件在相应运行级别的目录创建或删除链接文件。
 
懂得这个原理后,我们用手工的方法也可以完成这个操作,而且可以把这个方法运用在各种unix/linux操作系统,要程序随系统开机启动就不是难事了。
 
 
                                                                                                      2007-12-20

本文出自 “sery” 博客,转载请与作者联系!