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 工具类 异常处理类CrashHandler
1.整体分析 1.1.源代码如下,可以直接Copy. public class CrashHandler implements Thread.UncaughtExceptionHandler { pr ...
- PHP.TP框架下商品项目的优化3-php封装下拉框函数
php封装下拉框函数 因为在项目中会经常使用到下拉框,所以根据一个表中的数据制作下拉框函数,以便调用 //使用一个表的数据做下拉框函数 function buildSelect($tableName, ...
- adb logcat 日志过滤
方法 1.采用wpa_supplicant:s *:v 排除wpa_supplicant标签 adb -s 01d32e89cb94d599 logcat -v time -s wpa_suppl ...
- PHP字符串word末字符大小写互换
要求 给出一个字符串如 “A journey of, a thousand 'miles' must can't \"begin\" with a single step.” ,通 ...
- 不吹不擂,你想要的Python面试都在这里了【315+道题】+精心整理的解答
Part01-Py基础篇(80) Part02-网络编程和并发(34) Part03-数据库和缓存(46) Part04-前端框架和其他(155) Part01-Py基础篇(80) 1.为什么学习Py ...
- sqlserver 列出表字段和字段说明
--表描述SELECT tbs.name 表名,ds.value 描述 FROM sys.extended_properties dsLEFT JOIN sysobjects tbs ON ds.ma ...
- 使用dib element proliant-tools制作deploy image
element proliant-tools会在ipa ramdisk中安装一个rpm包hpssacli(HP的RAID管理工具),和一个python module proliantutils(里面P ...
- Codeforces 1093G题解(线段树维护k维空间最大曼哈顿距离)
题意是,给出n个k维空间下的点,然后q次操作,每次操作要么修改其中一个点的坐标,要么查询下标为[l,r]区间中所有点中两点的最大曼哈顿距离. 思路:参考blog:https://blog.csdn.n ...
- HDU 1709 母函数天平问题 可出现减法的情况 The Balance
The Balance Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- PHP文件信息获取函数
知识点: basename():获取文件名,传入第二个参数则只显示文件名,不显示后缀 dirname():获取文件路径 pathinfo():将文件信息存入一个数组,通过索引basename,dirn ...