Chinaunix首页 | 论坛 | 博客
  • 博客访问: 194325
  • 博文数量: 44
  • 博客积分: 2021
  • 博客等级: 大尉
  • 技术积分: 937
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-03 22:55
文章分类

全部博文(44)

文章存档

2009年(2)

2008年(42)

我的朋友

分类: LINUX

2008-04-13 15:31:21

/etc/inittab
id:3:initdefault:
in this file,number 3 is the default runlevel.


[root@workstation rc.d]# pwd
/etc/rc.d
[root@workstation rc.d]# ll
total 100
drwxr-xr-x  2 root root  4096 Feb  1 03:45 init.d
-rwxr-xr-x  1 root root  2352 Mar 17  2004 rc
drwxr-xr-x  2 root root  4096 Dec 17 07:21 rc0.d
drwxr-xr-x  2 root root  4096 Dec 17 07:21 rc1.d
drwxr-xr-x  2 root root  4096 Jan 29 11:11 rc2.d
drwxr-xr-x  2 root root  4096 Apr 12 12:56 rc3.d
drwxr-xr-x  2 root root  4096 Jan 29 11:11 rc4.d
drwxr-xr-x  2 root root  4096 Feb  1 03:45 rc5.d
drwxr-xr-x  2 root root  4096 Dec 17 07:21 rc6.d
-rwxr-xr-x  1 root root   555 Jan 24 17:35 rc.local
-rwxr-xr-x  1 root root 27253 Nov 18 21:47 rc.sysinit

These rc(0-6).d directory typically contain symbolic links that point back to the scripts in init.d directory.The names of these sysmbolic links all start with S or K followed by a number and the name of the service that the script control(e.g.S55sshd).When init transitions from a lower run level to a higher one,it runs all the scripts that start with S in ascending numerical order with ther argument start.When init transitions from a higher run level to a lower one,it runs all the scripts that start with K(for kill) in descending numerical order with the argument stop.

test in red hat enterprise linux 4
when you execute command telinit 1 from runlevel 3,the symbolic links that start with K fellowed by a number in /etc/rc.d/rc1.d will begin to execute ascendingly.

when you execute command telinit 3 from runlevel 1, the symbolic links that start with S fellowed by a number in /etc/rc.d/rc3.d will begin to execute ascendingly.

like this S1command----------->S10command from lowlevel to highlevel
          K1command----------->K10command from highlevel to lowlevel


S means start
K means kill

for example:
[root@workstation rc3.d]# pwd
/etc/rc.d/rc3.d
[root@workstation rc3.d]# ll
total 0
lrwxrwxrwx  1 root root 13 Dec 13 09:23 K01yum -> ../init.d/yum
lrwxrwxrwx  1 root root 19 Mar 15  2006 K02haldaemon -> ../init.d/haldaemon
lrwxrwxrwx  1 root root 24 May 19  2007 K02NetworkManager -> ../init.d/NetworkManager
lrwxrwxrwx  1 root root 20 Mar 15  2006 K03messagebus -> ../init.d/messagebus
lrwxrwxrwx  1 root root 15 Dec 17 07:21 K03rhnsd -> ../init.d/rhnsd
lrwxrwxrwx  1 root root 17 Mar 15  2006 K05anacron -> ../init.d/anacron
lrwxrwxrwx  1 root root 13 Mar 15  2006 K05atd -> ../init.d/atd
lrwxrwxrwx  1 root root 19 Mar 15  2006 K05saslauthd -> ../init.d/saslauthd
lrwxrwxrwx  1 root root 14 Mar 15  2006 K10cups -> ../init.d/cups
lrwxrwxrwx  1 root root 16 Mar 15  2006 K10psacct -> ../init.d/psacct
lrwxrwxrwx  1 root root 13 Mar 15  2006 K10xfs -> ../init.d/xfs
lrwxrwxrwx  1 root root 13 Mar 15  2006 K15gpm -> ../init.d/gpm
lrwxrwxrwx  1 root root 13 Mar 15  2006 K20nfs -> ../init.d/nfs
lrwxrwxrwx  1 root root 14 Mar 15  2006 K24irda -> ../init.d/irda
lrwxrwxrwx  1 root root 18 Sep 24  2007 K30sendmail -> ../init.d/sendmail
lrwxrwxrwx  1 root root 16 Mar 15  2006 K40smartd -> ../init.d/smartd
lrwxrwxrwx  1 root root 20 Mar 15  2006 K44rawdevices -> ../init.d/rawdevices
lrwxrwxrwx  1 root root 17 Mar 15  2006 K50netdump -> ../init.d/netdump
lrwxrwxrwx  1 root root 15 Jan 24 17:13 K50snmpd -> ../init.d/snmpd
lrwxrwxrwx  1 root root 19 Mar 30  2006 K50snmptrapd -> ../init.d/snmptrapd
lrwxrwxrwx  1 root root 16 Jan 29 11:11 K50vsftpd -> ../init.d/vsftpd
lrwxrwxrwx  1 root root 16 Mar 15  2006 K50xinetd -> ../init.d/xinetd
lrwxrwxrwx  1 root root 15 Mar 15  2006 K56acpid -> ../init.d/acpid
lrwxrwxrwx  1 root root 19 Mar 15  2006 K68rpcidmapd -> ../init.d/rpcidmapd
lrwxrwxrwx  1 root root 17 Mar 15  2006 K69rpcgssd -> ../init.d/rpcgssd
lrwxrwxrwx  1 root root 16 Mar 15  2006 K72autofs -> ../init.d/autofs
lrwxrwxrwx  1 root root 16 Mar 15  2006 K73ypbind -> ../init.d/ypbind
lrwxrwxrwx  1 root root 14 Mar 15  2006 K74apmd -> ../init.d/apmd
lrwxrwxrwx  1 root root 14 Mar 15  2006 K74nscd -> ../init.d/nscd
lrwxrwxrwx  1 root root 15 Dec 17 07:21 K75netfs -> ../init.d/netfs
lrwxrwxrwx  1 root root 19 Dec 17 07:19 K85mdmonitor -> ../init.d/mdmonitor
lrwxrwxrwx  1 root root 15 Dec 17 07:19 K85mdmpd -> ../init.d/mdmpd
lrwxrwxrwx  1 root root 17 Mar 15  2006 K86nfslock -> ../init.d/nfslock
lrwxrwxrwx  1 root root 16 Mar 15  2006 K87auditd -> ../init.d/auditd
lrwxrwxrwx  1 root root 20 Mar 15  2006 K87irqbalance -> ../init.d/irqbalance
lrwxrwxrwx  1 root root 17 Mar 15  2006 K87portmap -> ../init.d/portmap
lrwxrwxrwx  1 root root 18 Mar 15  2006 K89netplugd -> ../init.d/netplugd
lrwxrwxrwx  1 root root 15 May 19  2007 K89rdisc -> ../init.d/rdisc
lrwxrwxrwx  1 root root 19 Mar 15  2006 K90bluetooth -> ../init.d/bluetooth
lrwxrwxrwx  1 root root 14 Mar 15  2006 K91isdn -> ../init.d/isdn
lrwxrwxrwx  1 root root 18 Mar 15  2006 K92iptables -> ../init.d/iptables
lrwxrwxrwx  1 root root 18 Mar 15  2006 K94diskdump -> ../init.d/diskdump
lrwxrwxrwx  1 root root 15 Mar 15  2006 K95kudzu -> ../init.d/kudzu
lrwxrwxrwx  1 root root 16 Mar 15  2006 K96pcmcia -> ../init.d/pcmcia
lrwxrwxrwx  1 root root 23 Mar 15  2006 K99microcode_ctl -> ../init.d/microcode_ctl
lrwxrwxrwx  1 root root 19 Mar 15  2006 K99readahead -> ../init.d/readahead
lrwxrwxrwx  1 root root 25 Mar 15  2006 K99readahead_early -> ../init.d/readahead_early
lrwxrwxrwx  1 root root 22 Dec 17 07:17 S02lvm2-monitor -> ../init.d/lvm2-monitor
lrwxrwxrwx  1 root root 18 Mar 15  2006 S06cpuspeed -> ../init.d/cpuspeed
lrwxrwxrwx  1 root root 17 Dec 17 07:21 S10network -> ../init.d/network
lrwxrwxrwx  1 root root 16 Mar 15  2006 S12syslog -> ../init.d/syslog
lrwxrwxrwx  1 root root 20 Mar 30  2006 S26lm_sensors -> ../init.d/lm_sensors
lrwxrwxrwx  1 root root 14 Mar 15  2006 S55sshd -> ../init.d/sshd
lrwxrwxrwx  1 root root 14 Nov 15 21:17 S58ntpd -> ../init.d/ntpd
lrwxrwxrwx  1 root root 15 Sep  9  2007 S64mysql -> ../init.d/mysql
lrwxrwxrwx  1 root root 15 Mar 15  2006 S90crond -> ../init.d/crond
lrwxrwxrwx  1 root root 20 Feb  1 03:45 S99bbc -> /etc/rc.d/init.d/bbc
lrwxrwxrwx  1 root root 11 Dec 17 07:21 S99local -> ../rc.local

This scheme gives administrators fine-grained control of the order in which services are started.For example, it doesn't make sense to start SSH before the network interfaces are up.Although the network and sshd are both configured to start at run level 3 on system,the network script gets sequence number 10 and the sshd script gets sequence number 55,so network is certain to be run first.Be sure to consider this type of dependency when you add a new service.

To tell system when to start a daemon,you must place symbolic links into the appropriate directory.For example, to tell the system to start CUPS at run level2 and stop it nicely before shutting down,the fellowing pair of links would suffice.
#ln -s /etc/init.d/cups /etc/rc2.d/S80cups
#ln -s /etc/init.d/cups /etc/rc0.d/K80cups
The first line tells the system to run the /etc/init.d/cups startup script as one of the last things to do when entering run level2 and run the script with the start argument.The second line tells the system to run /etc/init.d/cups relatively soon when shutting down the system and to run the script with the stop argument.Some systems treat shutdown and reboot differently,so we have to put a symbolic link in the /etc/rc6.d directory as well to make sure the daemon shuts down properly when the system is rebooted.


all the rc(0-6).d directory in /etc dirctory are the symbolic links from /etc/rc.d/
阅读(582) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~