Linux_inittab文件剖析
[root@localhost ~]# cat /etc/inittab //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: 系统默认启动的运行等级 5:图形界面
# 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: 系统默认启动的运行等级 5:图形界面
# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit rc.sysinit是一个脚本,只要开机都有运行,无论什么运行级别
rc.sysinit脚本完成系统服务程序启动,如系统环境变量设置,系统时钟设置,
检查加载文件系统,生成系统启动信息日志文件等等
wait: 执行process中的命令,等其结束后在运行其他命令
//once:执行process中的命令,不等待结束
l0:0:wait:/etc/rc.d/rc 0 run level 0 关机
l1:1:wait:/etc/rc.d/rc 1 run level 1 但用户模式; 没有图形界面,用于root用户对系统进行维护
l2:2:wait:/etc/rc.d/rc 2 run level 2 多用户模式; 在该模式下不能使用NFS
l1:1:wait:/etc/rc.d/rc 1 run level 1 但用户模式; 没有图形界面,用于root用户对系统进行维护
l2:2:wait:/etc/rc.d/rc 2 run level 2 多用户模式; 在该模式下不能使用NFS
l3:3:wait:/etc/rc.d/rc 3 run level 3 完全多用户模式; 主机作为服务器时通常在该模式下
l4:4:wait:/etc/rc.d/rc 4 run level 4 未分配使用; 可以自定义的级别
l5:5:wait:/etc/rc.d/rc 5 run level 5 图形登陆的多用户模式: 用户在该模式下可以进行图形界面的登陆
l6:6:wait:/etc/rc.d/rc 6 run level 6 重新启动
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
[root@localhost ~]# ls /etc/rc.d /etc/rc.d是系统运行等级文件所在目录
显示系统0~6运行级别文件
系统会去找对应的开机运行级别文件,加载对应的开机运行等级文件里的服务
init.d rc rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rc.local rc.sysinit
init.d rc rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rc.local rc.sysinit
[root@localhost ~]# ls /etc/rc.d/rc3.d 显示运行级别3里的文件
1.字母 S;start;启动服务 K;kill; 关闭服务
2.数字 定义脚本启动顺序
3.名称 脚本的名称
K69rpcsvcgssd K91capi S11auditd S25pcscd S90crondK01dnsmasq K73ypbind K99readahead_later S12restorecond S26acpid S90xfs
K02avahi-dnsconfd K74ipmi S00microcode_ctl S12syslog S26apmd S95anacron
K02NetworkManager K74nscd S02lvm2-monitor S13irqbalance S26haldaemon S95atd
K05conman K74ntpd S03vmware-tools S13portmap S26hidd S97rhnsd
K05saslauthd K80kdump S04readahead_early S14nfslock S28autofs S97yum-updatesd
K05wdaemon K85mdmpd S05kudzu S15mdmonitor S50hplip S98avahi-daemon
K10psacct K87multipathd S06cpuspeed S18rpcidmapd S55sshd S99firstboot
K20nfs K88wpa_supplicant S08ip6tables S19rpcgssd S56cups S99local
K24irda K89dund S08iptables S22messagebus S56rawdevices S99smartd
K35vncserver K89netplugd S08mcstrans S23setroubleshoot S56xinetd
K35winbind K89pand S09isdn S25bluetooth S80sendmail
K50netconsole K89rdisc S10network S25netfs S85gpm
K02avahi-dnsconfd K74ipmi S00microcode_ctl S12syslog S26apmd S95anacron
K02NetworkManager K74nscd S02lvm2-monitor S13irqbalance S26haldaemon S95atd
K05conman K74ntpd S03vmware-tools S13portmap S26hidd S97rhnsd
K05saslauthd K80kdump S04readahead_early S14nfslock S28autofs S97yum-updatesd
K05wdaemon K85mdmpd S05kudzu S15mdmonitor S50hplip S98avahi-daemon
K10psacct K87multipathd S06cpuspeed S18rpcidmapd S55sshd S99firstboot
K20nfs K88wpa_supplicant S08ip6tables S19rpcgssd S56cups S99local
K24irda K89dund S08iptables S22messagebus S56rawdevices S99smartd
K35vncserver K89netplugd S08mcstrans S23setroubleshoot S56xinetd
K35winbind K89pand S09isdn S25bluetooth S80sendmail
K50netconsole K89rdisc S10network S25netfs S85gpm
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
# 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
respawn:一旦respawn指定的命令终止,便重新运行该命令
# Runxdm in runlevel 5
x:5:respawn:/etc/X11/prefdm -nodaemon 运行级别5,启动X window
id:runlevels:action:process
id: 标识符,一般为两位字母或数字
run-levels: 指定运行级别,可以指定多个
action: 指定运行状态
process: 指定要运行的脚本/命令