ubuntu启动脚本一览分析
#rc--run command的意思【rc解释】
harvey@ubuntu:/etc$ cat ./init/rc-sysinit.conf
# rc-sysinit - System V initialisation compatibility
#
# This task runs the old System V-style system initialisation scripts,
# and enters the default runlevel when finished.
#选定系统的启动级别,还没有真正进入系统启动阶段
description "System V initialisation compatibility"
author "Scott James Remnant <scott@netsplit.com>" start on (filesystem and static-network-up) or failsafe-boot
stop on runlevel # Default runlevel, this may be overriden on the kernel command-line
# or by faking an old /etc/inittab entry
#设置默认的启动级别为2,但是当有inittab文件和内核命令行的时候默认值会被改变
env DEFAULT_RUNLEVEL= emits runlevel # There can be no previous runlevel here, but there might be old
# information in /var/run/utmp that we pick up, and we don't want
# that.
#
# These override that
#防止/var/run/utmp下面旧的启动信息干扰,把信息置空
env RUNLEVEL=
env PREVLEVEL= console output
env INIT_VERBOSE task
#如果存在inittab文件就按照inittab的要求计算默认DEFAULTLEVEL
script
# Check for default runlevel in /etc/inittab
if [ -r /etc/inittab ]
then
eval "$(sed -nre 's/^[^#][^:]*:([0-6sS]):initdefault:.*/DEFAULT_RUNLEVEL="\";/p' /etc/inittab || true)"
fi # Check kernel command-line for typical arguments
for ARG in $(cat /proc/cmdline)
do
case "${ARG}" in
-b|emergency)
# Emergency shell
[ -n "${FROM_SINGLE_USER_MODE}" ] || sulogin
;;
[0123456sS])
# Override runlevel
DEFAULT_RUNLEVEL="${ARG}"
;;
-s|single)
# Single user mode
[ -n "${FROM_SINGLE_USER_MODE}" ] || DEFAULT_RUNLEVEL=S
;;
esac
done # Run the system initialisation scripts
#执行系统内核脚本改变DEFAULTLEVEL的值
[ -n "${FROM_SINGLE_USER_MODE}" ] || /etc/init.d/rcS # Switch into the default runlevel
#开放根据选定的level启动系统
telinit "${DEFAULT_RUNLEVEL}" #执行telinit命令
end script
在ubuntu下init 和telinit都是二进制命令:
harvey@ubuntu:/etc$ ll /sbin/init /sbin/telinit
-rwxr-xr-x root root 1月 /sbin/init*
-rwxr-xr-x root root 1月 /sbin/telinit*
ubuntu启动流程:
Ubuntu的upstart init文件→→进入/etc/init文件夹下选择进入的level值→→进入/etc/rc{level}.d文件夹,根据文件夹内的软连接的名字判断执行方式→→实际进入/etc/init.d文件夹执行命令
harvey@ubuntu:/etc/rc2.d$ ll #rc2.d 文件夹下都是链接到init.d文件夹中的软连接,软连接以S开头表示启动服务K开头的表示停止,rc{level}.d文件夹类似于windows的启动文件夹,windows中放入启动文件夹中的程序会被启动
总用量
drwxr-xr-x root root 3月 : ./
drwxr-xr-x root root 3月 ../
-rw-r--r-- root root 7月 README
lrwxrwxrwx root root 3月 : S20kerneloops -> ../init.d/kerneloops*
#exec="/usr/sbin/kerneloops"执行该程序,并把pid保存在/var/run/$prog.pid使用的conf是/etc/kerneloops.conf文件【证明usr放的是程序代码,var防止运行时信息】
lrwxrwxrwx root root 3月 : S20speech-dispatcher -> ../init.d/speech-dispatcher*
#服务程序位置daemon="/usr/bin/speech-dispatcher" 进程文件信息PIDFILE=/var/run/speech-dispatcher/speech-dispatcher.pid 进程所属用户user='speech-dispatcher'
lrwxrwxrwx root root 3月 : S21sendmail -> ../init.d/sendmail*
#服务程序位置/usr/sbin/sendmail 脚本文件位置 /etc/init.d/sendmail
lrwxrwxrwx root root 3月 : S35whereami -> ../init.d/whereami*
#strat whereami
lrwxrwxrwx root root 3月 : S50pulseaudio -> ../init.d/pulseaudio*
#服务程序位置/usr/bin/pulseaudio PID文件位置/var/run/pulse
lrwxrwxrwx root root 3月 : S50rsync -> ../init.d/rsync*
#服务位置/usr/bin/rsync
lrwxrwxrwx root root 3月 : S50saned -> ../init.d/saned*
#daemon服务的位置 /usr/sbin/saned
lrwxrwxrwx root root 3月 : S70dns-clean -> ../init.d/dns-clean*
lrwxrwxrwx root root 3月 : S70pppd-dns -> ../init.d/pppd-dns*
lrwxrwxrwx root root 3月 : S75sudo -> ../init.d/sudo*
lrwxrwxrwx root root 3月 : S99acpi-support -> ../init.d/acpi-support*
lrwxrwxrwx root root 3月 : S99grub-common -> ../init.d/grub-common*
lrwxrwxrwx root root 3月 : S99ondemand -> ../init.d/ondemand*
lrwxrwxrwx root root 3月 : S99rc.local -> ../init.d/rc.local* #
ubuntu用runlevel查看当前运行的级别,用sudo init {num}来切换工作的level。level0 表示关键 level6表示重启动 level2是默认级别
harvey@ubuntu:~$ runlevel #查看当前工作level
N
harvey@ubuntu:~$ sudo init #shutdown和reboot就是切换的runleve
参考资料:ubuntu为什么没有/etc/inittab文件? 深究ubuntu的启动流程分析
ubuntu启动脚本一览分析的更多相关文章
- ubuntu启动脚本
下午分析了一下mysql的启动脚本,找到这篇,记录一下,目前很多服务都是以这种方式封装,后面自己写来借鉴一下 http://blog.fens.me/linux-upstart/
- HBase配置&启动脚本分析
本文档基于hbase-0.96.1.1-cdh5.0.2,对HBase配置&启动脚本进行分析 date:2016/8/4 author:wangxl HBase配置&启动脚本分析 剔除 ...
- Spark配置&启动脚本分析
本文档基于Spark2.0,对spark启动脚本进行分析. date:2016/8/3 author:wangxl Spark配置&启动脚本分析 我们主要关注3类文件,配置文件,启动脚本文件以 ...
- linux系统 initrd.img中init启动脚本分析
概述:这篇文章主体内容来源于网上转载.前面几篇文章倾向于制作initrd.img,这篇文章更倾向于initrd.img的运行过程:加载framebuff驱动 ide驱动和文件系统驱动,最后进入到真正的 ...
- busybox rootfs 启动脚本分析(二)
上次分析了busybox的启动脚本,这次分析一下init.d中一些脚本的内容. 参考链接 http://www.cnblogs.com/helloworldtoyou/p/6169678.html h ...
- [Tomcat 源码分析系列] (二) : Tomcat 启动脚本-catalina.bat
概述 Tomcat 的三个最重要的启动脚本: startup.bat catalina.bat setclasspath.bat 上一篇咱们分析了 startup.bat 脚本 这一篇咱们来分析 ca ...
- [Tomcat 源码分析系列] (一) : Tomcat 启动脚本-startup.bat
概述 我们通常使用 Tomcat 中的 startup.bat 来启动 Tomcat. 但是这其中干了一些什么事呢? 大家都知道一个 Java 程序需要启动的话, 肯定需要 main 方法, 那么这个 ...
- 关于Ubuntu运行级别、开机启动脚本的说明
关于Ubuntu运行级别.开机启动脚本的说明 目录简介 1.1介绍Ubuntu下面的自启动脚本目录 1.2 Linux操作系统运行级别的概念 1.3关于操作系统自启脚本的启动顺序 1.4 Lin ...
- 老李推荐:第5章3节《MonkeyRunner源码剖析》Monkey原理分析-启动运行: 启动脚本
老李推荐:第5章3节<MonkeyRunner源码剖析>Monkey原理分析-启动运行: 启动脚本 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性 ...
随机推荐
- Android 快捷方式的创建与查询 快捷方式问题大全 获取快捷方式在Launcher数据库中的信息 Failed to find provider info for com.android.la
/** * 创建添加快捷方式 * 其中需要设置的有: * 1. 快捷方式的标题 * 2. 快捷方式的图标 * 3. 点击快捷方式后的跳转 */ public static void createSho ...
- Android stadio 自定义debug release keystore
1.添加siggnig name 随意,不过按我写的就可以了.设置完成之后,你的build.grade就会多出来一些: android { signingConfigs { signingConfig ...
- linux 多播
1.概念 单播是用于两个主机之间传送数据,广播是一个主机对局域网内的所有主机发送数据.而多播,又称为组播,它是对一组特定的主机通信.将网络上同一类型 业务逻辑上分组,只和组内的成员通信,其它主机没有加 ...
- 设计模式之第22章-组合模式(Java实现)
设计模式之第22章-组合模式(Java实现) “鱼哥,有没有什么模式是用来处理树形的“部分与整体”的层次结构的啊.”“当然”“没有?”“有啊.别急,一会人就到了.” 组合模式之自我介绍 “请问你是?怎 ...
- cocos2d安装
cocos2d引擎要求Python 2 为2.6 以上版本,Python 3 为3.3以上版本 cocos2d引擎安装支持pip安装,安装指令如下: pip install cocos2d
- [C++] 数据结构应用——链表
C++ 数据结构应用--链表 代码已经封装成class啦,方便使用. 头文件:Linklist.h #include <iostream> /*********************** ...
- python 常见的错误类型 和 继承关系
BaseException +-- SystemExit #系统结束 +-- KeyboardInterrupt #键盘中断 ctrl+D +-- GeneratorExit #主动结束 +-- Ex ...
- nyoj 题目 孪生素数问题
孪生素数问题 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 写一个程序,找出给出素数范围内的所有孪生素数的组数.一般来说,孪生素数就是指两个素数距离为2,近的不能再 ...
- DevExpress的GridControl控件设置自定义显示方法
比如要显示性别为字符串,数据库中保存为数值(1:男,2:女,3:未知). 方法一: 点击控件上的"Run Designer"按钮,进入设计界面. 选择“Columns", ...
- AJAX提交表单后要清空,否则再次提交原来的数据会认为重复提交,提交失败。使用ajaxSubmit 函数需要引入jquery.form.min.js 文件
<script src="../../Scripts/js/jquery.form.min.js" type="text/javascript">& ...