一、linux启动过程
1、开机自检(硬件、cpu、主板、内存等)
2、读硬盘的0柱面0磁道1扇区的前446byte,446字节中有引导程序(根据启动顺利把任务交给相应的硬件。1扇区总共512字节,只读446字节,剩下的66给4个分区,2个给分区结束标志)
3、grup引导菜单
4、加载内核kernel
5、启动init进程(第一个启动的进程ps -ef|grep init可查看,为1)
6、读取inittab文件,执行rc.sysinit rc等脚本
/etc/inittab (运行级别脚本,可以更改开机运行级别)
/etc/ec.d/rc.sysinit
/etc/rc.d/rc3.d (文本模式)
7、启动mingetty,进入系统登入界面
精简开机系统启动
作用:减少安全隐患,减少资源占用
二、创建服务脚本
过程:创建/etc/init.d/chen1脚本,给/etc/init.d/chen1添加权限,为了符合chkconfig的脚本格式,我们需要在/etc/init.d/chen1写开头文件。写完之后chen1添加成chkcinfig管理。脚本的使用chkconfig chenq1 on即可。2345级别若没设置,系统默认是被设置的。
例:运行设置的是运行级别三,那么关闭或者打开该服务后,级别三里面的链接文件会更改
[root@Chen rc3.d]# vim /etc/init.d/chen (脚本必须要写在/etc/init.d/)
[root@Chen rc3.d]# chmod +x /etc/init.d/chen (脚本授权)
[root@Chen rc3.d]# vim /etc/init.d/chen (把脚本信息写进去)
[root@Chen rc3.d]# cat /etc/init.d/chen (确认脚本信息)
# chkconfig: 3 67 22
# description: chen by chenqj at 1
echo i like you
[root@Chen rc3.d]# chkconfig --add chen (进行关联服务)
[root@Chen rc3.d]# chkconfig --list chen
chen 0:off 1:off 2:off 3:on 4:off 5:off 6:off
[root@Chen rc3.d]# ll /etc/rc.d/rc3.d/|grep chen
lrwxrwxrwx. 1 root root 14 Oct 4 06:40 S67chen -> ../init.d/chen
[root@Chen rc3.d]# chkconfig chen off
[root@Chen rc3.d]# chkconfig --list chen
chen 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@Chen rc3.d]# ll /etc/rc.d/rc3.d|grep chen
lrwxrwxrwx. 1 root root 14 Oct 4 06:43 K22chen -> ../init.d/chen