第二部分 Linux Shell高级编程技巧——第三章 运行级别脚本介绍

笔记

 

#运行级别脚本介绍
#准备工作
#进入目录
cd /home/wgb/shell
#建立文件夹
mkdir 0421
#进入目录
cd 0421

#运行级别
#运行级别目录
#进入etc目录
[root@localhost etc]# cd /etc
#ls rc后按tab键,显示rc开头的文件或者目录
[root@localhost etc]# ls rc
rc          rc.news     rc1.d       rc4.d       
rc.d        rc.sysinit  rc2.d       rc5.d       
rc.local    rc0.d       rc3.d       rc6.d    
#获得当前运行级别
[root@localhost etc]# runlevel
N 5
#进入目录
[root@localhost etc]# cd rc5.d
#显示内容
[root@localhost rc5.d]# ls
K05innd            K50snmpd          S09isdn
K05saslauthd       K50snmptrapd      S10network
K09privoxy         K50tux            S12syslog
K10psacct          K50vsftpd         S13irqbalance
K12mailman         K54pxe            S13portmap
K15httpd           K55routed         S14nfslock
K15postgresql      K61ldap           S17keytable
K16rarpd           K65identd         S20random
K20bootparamd      K65kadmin         S24pcmcia
K20iscsi           K65kprop          S25netfs
K20netdump-server  K65krb524         S26apmd
K20nfs             K65krb5kdc        S28autofs
K20rstatd          K70aep1000        S55sshd
K20rusersd         K70bcm5820        S56rawdevices
K20rwalld          K74ntpd           S56xinetd
K20rwhod           K74ups            S59hpoj
K24irda            K74ypserv         S80sendmail
K25squid           K74ypxfrd         S80spamassassin
K28amd             K84bgpd           S85gpm
K34dhcrelay        K84ospf6d         S90FreeWnn
K34yppasswdd       K84ospfd          S90canna
K35atalk           K84ripd           S90crond
K35dhcpd           K84ripngd         S90cups
K35vncserver       K85zebra          S90xfs
K35winbind         K90isicom         S91smb
K36lisa            K95firstboot      S95anacron
K40mars-nwe        S00microcode_ctl  S95atd
K45arpwatch        S03vmware-tools   S95jexec
K45named           S05kudzu          S97rhnsd
K45smartd          S08ip6tables      S99local
K46radvd           S08ipchains       S99mdmonitor
K50netdump         S08iptables
#S和K表示当前级别下的脚本 S:被启动 K:被终止
#列出详细信息,指向init.d目录下的对应文件
[root@localhost rc5.d]# ls -al
total 8
drwxr-xr-x    2 root     root         4096 Nov 26 09:42 .
drwxr-xr-x   10 root     root         4096 Nov 24 10:38 ..
lrwxrwxrwx    1 root     root           14 Sep 21  2011 K05innd -> ../init.d/innd
lrwxrwxrwx    1 root     root           19 Sep 21  2011 K05saslauthd -> ../init.d/saslauthd
lrwxrwxrwx    1 root     root           17 Sep 21  2011 K09privoxy -> ../init.d/privoxy
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K10psacct -> ../init.d/psacct
lrwxrwxrwx    1 root     root           17 Sep 21  2011 K12mailman -> ../init.d/mailman
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K15httpd -> ../init.d/httpd
lrwxrwxrwx    1 root     root           20 Sep 21  2011 K15postgresql -> ../init.d/postgresql
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K16rarpd -> ../init.d/rarpd
lrwxrwxrwx    1 root     root           20 Sep 21  2011 K20bootparamd -> ../init.d/bootparamd
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K20iscsi -> ../init.d/iscsi
lrwxrwxrwx    1 root     root           24 Sep 21  2011 K20netdump-server -> ../init.d/netdump-server
lrwxrwxrwx    1 root     root           13 Sep 21  2011 K20nfs -> ../init.d/nfs
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K20rstatd -> ../init.d/rstatd
lrwxrwxrwx    1 root     root           17 Sep 21  2011 K20rusersd -> ../init.d/rusersd
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K20rwalld -> ../init.d/rwalld
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K20rwhod -> ../init.d/rwhod
lrwxrwxrwx    1 root     root           14 Sep 21  2011 K24irda -> ../init.d/irda
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K25squid -> ../init.d/squid
lrwxrwxrwx    1 root     root           13 Sep 21  2011 K28amd -> ../init.d/amd
lrwxrwxrwx    1 root     root           18 Sep 21  2011 K34dhcrelay -> ../init.d/dhcrelay
lrwxrwxrwx    1 root     root           19 Sep 21  2011 K34yppasswdd -> ../init.d/yppasswdd
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K35atalk -> ../init.d/atalk
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K35dhcpd -> ../init.d/dhcpd
lrwxrwxrwx    1 root     root           19 Sep 21  2011 K35vncserver -> ../init.d/vncserver
lrwxrwxrwx    1 root     root           17 Sep 21  2011 K35winbind -> ../init.d/winbind
lrwxrwxrwx    1 root     root           14 Sep 21  2011 K36lisa -> ../init.d/lisa
lrwxrwxrwx    1 root     root           18 Sep 21  2011 K40mars-nwe -> ../init.d/mars-nwe
lrwxrwxrwx    1 root     root           18 Sep 21  2011 K45arpwatch -> ../init.d/arpwatch
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K45named -> ../init.d/named
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K45smartd -> ../init.d/smartd
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K46radvd -> ../init.d/radvd
lrwxrwxrwx    1 root     root           17 Sep 21  2011 K50netdump -> ../init.d/netdump
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K50snmpd -> ../init.d/snmpd
lrwxrwxrwx    1 root     root           19 Sep 21  2011 K50snmptrapd -> ../init.d/snmptrapd
lrwxrwxrwx    1 root     root           13 Sep 21  2011 K50tux -> ../init.d/tux
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K50vsftpd -> ../init.d/vsftpd
lrwxrwxrwx    1 root     root           13 Sep 21  2011 K54pxe -> ../init.d/pxe
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K55routed -> ../init.d/routed
lrwxrwxrwx    1 root     root           14 Sep 21  2011 K61ldap -> ../init.d/ldap
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K65identd -> ../init.d/identd
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K65kadmin -> ../init.d/kadmin
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K65kprop -> ../init.d/kprop
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K65krb524 -> ../init.d/krb524
lrwxrwxrwx    1 root     root           17 Sep 21  2011 K65krb5kdc -> ../init.d/krb5kdc
lrwxrwxrwx    1 root     root           17 Sep 21  2011 K70aep1000 -> ../init.d/aep1000
lrwxrwxrwx    1 root     root           17 Sep 21  2011 K70bcm5820 -> ../init.d/bcm5820
lrwxrwxrwx    1 root     root           14 Sep 21  2011 K74ntpd -> ../init.d/ntpd
lrwxrwxrwx    1 root     root           13 Sep 21  2011 K74ups -> ../init.d/ups
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K74ypserv -> ../init.d/ypserv
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K74ypxfrd -> ../init.d/ypxfrd
lrwxrwxrwx    1 root     root           14 Sep 21  2011 K84bgpd -> ../init.d/bgpd
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K84ospf6d -> ../init.d/ospf6d
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K84ospfd -> ../init.d/ospfd
lrwxrwxrwx    1 root     root           14 Sep 21  2011 K84ripd -> ../init.d/ripd
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K84ripngd -> ../init.d/ripngd
lrwxrwxrwx    1 root     root           15 Sep 21  2011 K85zebra -> ../init.d/zebra
lrwxrwxrwx    1 root     root           16 Sep 21  2011 K90isicom -> ../init.d/isicom
lrwxrwxrwx    1 root     root           19 Sep 21  2011 K95firstboot -> ../init.d/firstboot
lrwxrwxrwx    1 root     root           23 Sep 21  2011 S00microcode_ctl -> ../init.d/microcode_ctl
lrwxrwxrwx    1 root     root           22 Oct 19  2012 S03vmware-tools -> ../init.d/vmware-tools
lrwxrwxrwx    1 root     root           15 Sep 21  2011 S05kudzu -> ../init.d/kudzu
lrwxrwxrwx    1 root     root           19 Sep 21  2011 S08ip6tables -> ../init.d/ip6tables
lrwxrwxrwx    1 root     root           18 Sep 21  2011 S08ipchains -> ../init.d/ipchains
lrwxrwxrwx    1 root     root           18 Sep 21  2011 S08iptables -> ../init.d/iptables
lrwxrwxrwx    1 root     root           14 Sep 21  2011 S09isdn -> ../init.d/isdn
lrwxrwxrwx    1 root     root           17 Sep 21  2011 S10network -> ../init.d/network
lrwxrwxrwx    1 root     root           16 Sep 21  2011 S12syslog -> ../init.d/syslog
lrwxrwxrwx    1 root     root           20 Sep 21  2011 S13irqbalance -> ../init.d/irqbalance
lrwxrwxrwx    1 root     root           17 Sep 21  2011 S13portmap -> ../init.d/portmap
lrwxrwxrwx    1 root     root           17 Sep 21  2011 S14nfslock -> ../init.d/nfslock
lrwxrwxrwx    1 root     root           18 Sep 21  2011 S17keytable -> ../init.d/keytable
lrwxrwxrwx    1 root     root           16 Sep 21  2011 S20random -> ../init.d/random
lrwxrwxrwx    1 root     root           16 Sep 21  2011 S24pcmcia -> ../init.d/pcmcia
lrwxrwxrwx    1 root     root           15 Sep 21  2011 S25netfs -> ../init.d/netfs
lrwxrwxrwx    1 root     root           14 Sep 21  2011 S26apmd -> ../init.d/apmd
lrwxrwxrwx    1 root     root           16 Sep 21  2011 S28autofs -> ../init.d/autofs
lrwxrwxrwx    1 root     root           14 Sep 21  2011 S55sshd -> ../init.d/sshd
lrwxrwxrwx    1 root     root           20 Sep 21  2011 S56rawdevices -> ../init.d/rawdevices
lrwxrwxrwx    1 root     root           16 Sep 21  2011 S56xinetd -> ../init.d/xinetd
lrwxrwxrwx    1 root     root           14 Sep 21  2011 S59hpoj -> ../init.d/hpoj
lrwxrwxrwx    1 root     root           18 Sep 21  2011 S80sendmail -> ../init.d/sendmail
lrwxrwxrwx    1 root     root           22 Sep 21  2011 S80spamassassin -> ../init.d/spamassassin
lrwxrwxrwx    1 root     root           13 Sep 21  2011 S85gpm -> ../init.d/gpm
lrwxrwxrwx    1 root     root           17 Sep 21  2011 S90FreeWnn -> ../init.d/FreeWnn
lrwxrwxrwx    1 root     root           15 Sep 21  2011 S90canna -> ../init.d/canna
lrwxrwxrwx    1 root     root           15 Sep 21  2011 S90crond -> ../init.d/crond
lrwxrwxrwx    1 root     root           14 Sep 21  2011 S90cups -> ../init.d/cups
lrwxrwxrwx    1 root     root           13 Sep 21  2011 S90xfs -> ../init.d/xfs
lrwxrwxrwx    1 root     root           13 Sep 21  2011 S91smb -> ../init.d/smb
lrwxrwxrwx    1 root     root           17 Sep 21  2011 S95anacron -> ../init.d/anacron
lrwxrwxrwx    1 root     root           13 Sep 21  2011 S95atd -> ../init.d/atd
lrwxrwxrwx    1 root     root           15 Nov 19 20:42 S95jexec -> ../init.d/jexec
lrwxrwxrwx    1 root     root           15 Sep 21  2011 S97rhnsd -> ../init.d/rhnsd
lrwxrwxrwx    1 root     root           11 Sep  8  2007 S99local -> ../rc.local
lrwxrwxrwx    1 root     root           19 Sep 21  2011 S99mdmonitor -> ../init.d/mdmonitor
#进入rc3.d目录
[root@localhost rc5.d]# cd ../rc3.d
#列出详细信息
[root@localhost rc3.d]# ls -al
total 8
drwxr-xr-x    2 root     root         4096 Nov 26 09:42 .
drwxr-xr-x   10 root     root         4096 Nov 24 10:38 ..
lrwxrwxrwx    1 root     root           14 Sep  8  2007 K05innd -> ../init.d/innd
lrwxrwxrwx    1 root     root           19 Sep  8  2007 K05saslauthd -> ../init.d/saslauthd
lrwxrwxrwx    1 root     root           17 Sep  8  2007 K09privoxy -> ../init.d/privoxy
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K10psacct -> ../init.d/psacct
lrwxrwxrwx    1 root     root           17 Sep  8  2007 K12mailman -> ../init.d/mailman
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K15httpd -> ../init.d/httpd
lrwxrwxrwx    1 root     root           20 Sep  8  2007 K15postgresql -> ../init.d/postgresql
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K16rarpd -> ../init.d/rarpd
lrwxrwxrwx    1 root     root           20 Sep  8  2007 K20bootparamd -> ../init.d/bootparamd
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K20iscsi -> ../init.d/iscsi
lrwxrwxrwx    1 root     root           24 Sep  8  2007 K20netdump-server -> ../init.d/netdump-server
lrwxrwxrwx    1 root     root           13 Sep  8  2007 K20nfs -> ../init.d/nfs
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K20rstatd -> ../init.d/rstatd
lrwxrwxrwx    1 root     root           17 Sep  8  2007 K20rusersd -> ../init.d/rusersd
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K20rwalld -> ../init.d/rwalld
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K20rwhod -> ../init.d/rwhod
lrwxrwxrwx    1 root     root           14 Sep  8  2007 K24irda -> ../init.d/irda
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K25squid -> ../init.d/squid
lrwxrwxrwx    1 root     root           13 Sep  8  2007 K28amd -> ../init.d/amd
lrwxrwxrwx    1 root     root           18 Sep  8  2007 K34dhcrelay -> ../init.d/dhcrelay
lrwxrwxrwx    1 root     root           19 Sep  8  2007 K34yppasswdd -> ../init.d/yppasswdd
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K35atalk -> ../init.d/atalk
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K35dhcpd -> ../init.d/dhcpd
lrwxrwxrwx    1 root     root           13 Sep  8  2007 K35smb -> ../init.d/smb
lrwxrwxrwx    1 root     root           19 Sep  8  2007 K35vncserver -> ../init.d/vncserver
lrwxrwxrwx    1 root     root           17 Sep  8  2007 K35winbind -> ../init.d/winbind
lrwxrwxrwx    1 root     root           14 Sep  8  2007 K36lisa -> ../init.d/lisa
lrwxrwxrwx    1 root     root           18 Sep  8  2007 K40mars-nwe -> ../init.d/mars-nwe
lrwxrwxrwx    1 root     root           18 Sep  8  2007 K45arpwatch -> ../init.d/arpwatch
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K45named -> ../init.d/named
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K45smartd -> ../init.d/smartd
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K46radvd -> ../init.d/radvd
lrwxrwxrwx    1 root     root           17 Sep  8  2007 K50netdump -> ../init.d/netdump
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K50snmpd -> ../init.d/snmpd
lrwxrwxrwx    1 root     root           19 Sep  8  2007 K50snmptrapd -> ../init.d/snmptrapd
lrwxrwxrwx    1 root     root           13 Sep  8  2007 K50tux -> ../init.d/tux
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K50vsftpd -> ../init.d/vsftpd
lrwxrwxrwx    1 root     root           13 Sep  8  2007 K54pxe -> ../init.d/pxe
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K55routed -> ../init.d/routed
lrwxrwxrwx    1 root     root           14 Sep  8  2007 K61ldap -> ../init.d/ldap
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K65identd -> ../init.d/identd
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K65kadmin -> ../init.d/kadmin
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K65kprop -> ../init.d/kprop
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K65krb524 -> ../init.d/krb524
lrwxrwxrwx    1 root     root           17 Sep  8  2007 K65krb5kdc -> ../init.d/krb5kdc
lrwxrwxrwx    1 root     root           17 Sep  8  2007 K70aep1000 -> ../init.d/aep1000
lrwxrwxrwx    1 root     root           17 Sep  8  2007 K70bcm5820 -> ../init.d/bcm5820
lrwxrwxrwx    1 root     root           14 Sep  7  2007 K74ntpd -> ../init.d/ntpd
lrwxrwxrwx    1 root     root           13 Sep  8  2007 K74ups -> ../init.d/ups
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K74ypserv -> ../init.d/ypserv
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K74ypxfrd -> ../init.d/ypxfrd
lrwxrwxrwx    1 root     root           14 Sep  8  2007 K84bgpd -> ../init.d/bgpd
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K84ospf6d -> ../init.d/ospf6d
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K84ospfd -> ../init.d/ospfd
lrwxrwxrwx    1 root     root           14 Sep  8  2007 K84ripd -> ../init.d/ripd
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K84ripngd -> ../init.d/ripngd
lrwxrwxrwx    1 root     root           15 Sep  8  2007 K85zebra -> ../init.d/zebra
lrwxrwxrwx    1 root     root           16 Sep  8  2007 K90isicom -> ../init.d/isicom
lrwxrwxrwx    1 root     root           19 Sep  7  2007 K95firstboot -> ../init.d/firstboot
lrwxrwxrwx    1 root     root           23 Sep  8  2007 S00microcode_ctl -> ../init.d/microcode_ctl
lrwxrwxrwx    1 root     root           22 Oct 19  2012 S03vmware-tools -> ../init.d/vmware-tools
lrwxrwxrwx    1 root     root           15 Sep  8  2007 S05kudzu -> ../init.d/kudzu
lrwxrwxrwx    1 root     root           19 Sep  8  2007 S08ip6tables -> ../init.d/ip6tables
lrwxrwxrwx    1 root     root           18 Sep  8  2007 S08ipchains -> ../init.d/ipchains
lrwxrwxrwx    1 root     root           18 Sep  8  2007 S08iptables -> ../init.d/iptables
lrwxrwxrwx    1 root     root           14 Sep  8  2007 S09isdn -> ../init.d/isdn
lrwxrwxrwx    1 root     root           17 Sep  8  2007 S10network -> ../init.d/network
lrwxrwxrwx    1 root     root           16 Sep  8  2007 S12syslog -> ../init.d/syslog
lrwxrwxrwx    1 root     root           20 Sep  8  2007 S13irqbalance -> ../init.d/irqbalance
lrwxrwxrwx    1 root     root           17 Sep  8  2007 S13portmap -> ../init.d/portmap
lrwxrwxrwx    1 root     root           17 Sep  8  2007 S14nfslock -> ../init.d/nfslock
lrwxrwxrwx    1 root     root           18 Sep  8  2007 S17keytable -> ../init.d/keytable
lrwxrwxrwx    1 root     root           16 Sep  8  2007 S20random -> ../init.d/random
lrwxrwxrwx    1 root     root           16 Sep  8  2007 S24pcmcia -> ../init.d/pcmcia
lrwxrwxrwx    1 root     root           15 Sep  8  2007 S25netfs -> ../init.d/netfs
lrwxrwxrwx    1 root     root           14 Sep  8  2007 S26apmd -> ../init.d/apmd
lrwxrwxrwx    1 root     root           16 Sep  8  2007 S28autofs -> ../init.d/autofs
lrwxrwxrwx    1 root     root           14 Sep  8  2007 S55sshd -> ../init.d/sshd
lrwxrwxrwx    1 root     root           20 Sep  8  2007 S56rawdevices -> ../init.d/rawdevices
lrwxrwxrwx    1 root     root           16 Sep  8  2007 S56xinetd -> ../init.d/xinetd
lrwxrwxrwx    1 root     root           14 Sep  8  2007 S59hpoj -> ../init.d/hpoj
lrwxrwxrwx    1 root     root           18 Sep  8  2007 S80sendmail -> ../init.d/sendmail
lrwxrwxrwx    1 root     root           22 Sep  8  2007 S80spamassassin -> ../init.d/spamassassin
lrwxrwxrwx    1 root     root           13 Sep  8  2007 S85gpm -> ../init.d/gpm
lrwxrwxrwx    1 root     root           17 Sep  8  2007 S90FreeWnn -> ../init.d/FreeWnn
lrwxrwxrwx    1 root     root           15 Sep  8  2007 S90canna -> ../init.d/canna
lrwxrwxrwx    1 root     root           15 Sep  8  2007 S90crond -> ../init.d/crond
lrwxrwxrwx    1 root     root           14 Sep  8  2007 S90cups -> ../init.d/cups
lrwxrwxrwx    1 root     root           13 Sep  8  2007 S90xfs -> ../init.d/xfs
lrwxrwxrwx    1 root     root           17 Sep  8  2007 S95anacron -> ../init.d/anacron
lrwxrwxrwx    1 root     root           13 Sep  8  2007 S95atd -> ../init.d/atd
lrwxrwxrwx    1 root     root           15 Nov 19 20:42 S95jexec -> ../init.d/jexec
lrwxrwxrwx    1 root     root           15 Sep  8  2007 S97rhnsd -> ../init.d/rhnsd
lrwxrwxrwx    1 root     root           11 Sep  8  2007 S99local -> ../rc.local
lrwxrwxrwx    1 root     root           19 Sep  8  2007 S99mdmonitor -> ../init.d/mdmonitor
#阿拉伯数字小先启动,大后启动




# inittab
#查看inittab文件内容
[root@localhost etc]# cat inittab
#
# inittab       This file describes how the INIT process should set up
#               the system in a certain run-level.
#
# Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
# 
id:5:initdefault:

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# When our UPS tells us power has failed, assume we have a few minutes
# of power left.  Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly.  
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"


# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

# Run xdm in runlevel 5
x:5:respawn:/etc/X11/prefdm –nodaemon
#作为服务器:默认为3
#学会查看帮助信息
#再次查看inittab文件
[root@localhost etc]# cat inittab
#
# inittab       This file describes how the INIT process should set up
#               the system in a certain run-level.
#
# Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
# 
id:5:initdefault:

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

# Things to run in every runlevel
ud:once:/sbin/update
#更改的内容
#checkdisk::once:/sbin/checkdisk.sh > /dev/console 2>&1
# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# When our UPS tells us power has failed, assume we have a few minutes
# of power left.  Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly.  
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"


# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

# Run xdm in runlevel 5
x:5:respawn:/etc/X11/prefdm -nodaemon


#启动应用程序
#启动脚本分析
#编辑文件
[root@localhost rc3.d]# vi S90crond 
#查看文件内容
[root@localhost rc3.d]# cat S90crond 
#! /bin/bash
#
# crond          Start/Stop the cron clock daemon.
#
# chkconfig: 2345 90 60
# description: cron is a standard UNIX program that runs user-specified \
#              programs at periodic scheduled times. vixie cron adds a \
#              number of features to the basic UNIX cron, including better \
#              security and more powerful configuration options.
# processname: crond
# config: /etc/crontab
# pidfile: /var/run/crond.pid

# Source function library.
. /etc/init.d/functions

RETVAL=0

# See how we were called.
  
prog="crond"

start() {
        echo -n $"Starting $prog: "
        daemon crond
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/crond
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        killproc crond
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/crond
        return $RETVAL
}

rhstatus() {
        status crond
}

restart() {
        stop
        start
}

reload() {
        echo -n $"Reloading cron daemon configuration: "
        killproc crond -HUP
        retval=$?
        echo
        return $RETVAL
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  reload)
        reload
        ;;
  status)
        rhstatus
        ;;
  condrestart)
        [ -f /var/lock/subsys/crond ] && restart || :
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
        exit 1
esac

exit $?
#启动脚本
service server start|stop|restart|…
srcipt_name start|stop|restart
#停止crond服务
[root@localhost rc3.d]# service crond stop
Stopping crond:                                            [  OK  ]
#启动crond服务
[root@localhost rc3.d]# service crond start
Starting crond: ^[[A                                       [  OK  ]
#重启crond服务
[root@localhost rc3.d]# service crond restart
Stopping crond:                                            [  OK  ]
Starting crond:                                            [  OK  ]
#查看crond服务状态
[root@localhost rc3.d]# service crond status 
crond (pid 3737) is running...
#进入inti.d目录
[root@localhost rc3.d]# cd ../init.d/
#列出所有内容
[root@localhost init.d]# ls
FreeWnn     gpm         krb5kdc         portmap     smartd
aep1000     halt        kudzu           postfix     smb
amd         hpoj        ldap            postgresql  snmpd
anacron     httpd       lisa            privoxy     snmptrapd
apmd        identd      lpd             psacct      spamassassin
arpwatch    innd        mailman         pxe         squid
atalk       ip6tables   mars-nwe        radvd       sshd
atd         ipchains    mdmonitor       random      syslog
autofs      iptables    microcode_ctl   rarpd       tux
bcm5820     irda        named           rawdevices  ups
bgpd        irqbalance  netdump         rhnsd       vmware-tools
bluetooth   iscsi       netdump-server  ripd        vncserver
bootparamd  isdn        netfs           ripngd      vsftpd
canna       isicom      network         routed      winbind
cpqarrayd   jexec       nfs             rstatd      xfs
crond       kadmin      nfslock         rusersd     xinetd
cups        kdcrotate   nscd            rwalld      ypbind
dhcpd       keytable    ntpd            rwhod       yppasswdd
dhcrelay    killall     ospf6d          saslauthd   ypserv
firstboot   kprop       ospfd           sendmail    ypxfrd
functions   krb524      pcmcia          single      zebra
[root@localhost init.d]# vi mysqld
#编写自己的服务,然后放在init.d目录下,再在对应的启动级别下加入超链接即可实现当机器启动时完成对相应服务的启动

 


 

附图

 

 

 

 

 

 

katoonSina  CSDN
@Wentasy 博文仅供参考,欢迎大家来访。如有错误之处,希望批评指正。原创博文如需转载请注明出处,谢谢 :) [CSDN博客]
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值