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 getLocationInWindow
参考博客: http://blog.sina.com.cn/s/blog_44d19b500102vpve.html 这篇博客,我看了三遍,终于看懂了.恩,我就喜欢这样不放弃的自己. 1.getLoc ...
- notepad++ 换行技巧 log换行
有时候,服务器收集上来的日志,格式很乱,看log很难,如下: java.lang.IllegalStateException: BEvent.init() must be call first\n\t ...
- Java学习笔记17---成员方法的重载与重写
重载是指,一个类中定义了一个成员方法后,通过修改参数个数.参数类型或参数顺序,重新实现该方法,则这两个方法互为对方的重载方法. 重写是指,子类重新实现父类的成员方法. 重载后的方法,与原方法相比: ( ...
- 强烈推荐android初学者,android进阶者看看这个系列教程
强烈推荐android初学者,android进阶者看看这个系列教程 转载 2015年05月30日 23:05:44 695 为什么要研究Android,是因为它够庞大,它够复杂,他激起了我作为一个程序 ...
- DOS程序员手册(九)
第14章参考手册概述 本书余下的章节将向读者们介绍BIOS.DOS各种各样API函数和服务,作为一名程 序员,了解和掌握这些知识是很有好处的.在所介绍的参考手册中,每部手册都汇集了大 量的资源 ...
- 【Max Points on a Line 】cpp
题目: Given n points on a 2D plane, find the maximum number of points that lie on the same straight li ...
- 【NOIP 2017 提高组】列队
题目 有一个 \(n\times m\) 的方阵,每次出来一个人后向左看齐,向前看齐,询问每次出来的人的编号. \(n\le 3\times 10^5\) 分析 我们考虑离队本质上只有两种操作: 删除 ...
- unity生命周期
1.静态构造函数 当程序集被加载的时候就被调用了,如果你的unity处于编辑状态时,此时你保存一个脚本(从而迫使重新编译),静态构造函数会立即被调用,因为unity加载了DLL.并且它将不会再次运行, ...
- IPV4的地址是如何分类的?网络号的范围分别是多少?
1. A类地址 (1)A类地址第1字节为网络地址,其它3个字节为主机地址. (2)A类地址范围:1.0.0.1—126.255.255.254 (3)A类地址中的私有地址和保留地址: ① 10.X.X ...
- 【bzoj3289】Mato的文件管理 离散化+莫队算法+树状数组
原文地址:http://www.cnblogs.com/GXZlegend/p/6805224.html 题目描述 Mato同学从各路神犇以各种方式(你们懂的)收集了许多资料,这些资料一共有n份,每份 ...