原文:http://blog.csdn.net/justdb/article/details/9621271 版权声明:本文为博主原创文章。

Linux系统的启动时通过读取不同的配置文件,执行相应的Shell脚本完成的。当然本文只是简单的从文件的角度分析,更深层次的本文没涉及。

主要读取了以下文件:

 /boot/grub/grub.conf
/etc/inittab
/etc/rc5.d(rc.d) - Seq
/etc/passwd (Login,input username and password)
/etc/shadow
/etc/profile:init the env var of user
/etc/profile.d/*.sh
~/.bash_profile
~/.bash_history
~/.bashrc
/etc/bashrc

我们首先来看grub.conf文件

 [root@larrywen grub]# ll menu.lst
lrwxrwxrwx. root root 7o?=o?= : menu.lst -> ./grub.conf
[root@larrywen grub]# pwd
/boot/grub
grub.conf文件内容:
default=
timeout=
splashimage=(hd0,)/boot/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux (2.6.-.el6.i686)
root (hd0,)
kernel /boot/vmlinuz-2.6.-.el6.i686 ro
root=UUID=ed98469d-857b-4ae5-91e4-118e0167ead7 rd_NO_LUKS rd_NO_LVM
LANG=en_US.UTF- rd_NO_MD quiet SYSFONT=lat arcyrheb-sun16 rhgb
crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
initrd /boot/initramfs-2.6.-.el6.i686.img

执行runlevel命令可以看到启动级别是5

 [root@larrywen grub]# runlevel
N

我们进入etc目录,可以看到很多rcX.d目录

 [root@larrywen grub]# cd /etc/init.d  

 [root@larrywen init.d]# cd /etc
[root@larrywen etc]# cd rc
rc rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/
rc6.d/ rc.d/ rc.local rc.sysinit

我们进入/etc/profile.d目录,可以看到很多可执行脚本

 [root@localhost test]# ll /etc/profile.d/*.sh
-rw-r--r--. 1 root root 1143 Apr 28 2010 /etc/profile.d/colorls.sh
-rw-r--r--. 1 root root 78 Apr 21 2010 /etc/profile.d/cvs.sh
-rw-r--r--. 1 root root 192 Dec 12 2005 /etc/profile.d/glib2.sh
-rw-r--r--. 1 root root 70 Aug 12 2010 /etc/profile.d/gnome-ssh-askpass.sh
-rwxr-xr-x. 1 root root 288 Sep 24 2009 /etc/profile.d/kde.sh
-rw-r--r--. 1 root root 2706 Sep 2 2010 /etc/profile.d/lang.sh
-rw-r--r--. 1 root root 108 Feb 7 2007 /etc/profile.d/less.sh
-rw-r--r--. 1 root root 933 Jun 30 2010 /etc/profile.d/qt.sh
-rw-r--r--. 1 root root 2142 Sep 8 2010 /etc/profile.d/udisks-bash-completion.sh
-rw-r--r--. 1 root root 269 May 19 2010 /etc/profile.d/vim.sh
-rw-r--r--. 1 root root 169 May 20 2009 /etc/profile.d/which2.sh

因为启动级别是5,所以我们进入rc5.d,可以看到很多文件,S表示当系统启动时执行,K表示当系统关闭时执行。

[root@localhost grub]# ll /etc/rc5.d/
K01certmonger K50netconsole K75ntpdate K89rdisc S11auditd S24avahi-daemon S26pcscd S82abrtd
K01smartd K50snmpd K76ipsec K95cgconfig S11portreserve S24nfslock S26udev-post S85qpidd
K02oddjobd K50snmptrapd K80kdump K95firstboot S12rsyslog S24openct S28autofs S90crond
K10psacct K50vsftpd K80sblim-sfcb S00microcode_ctl S13cpuspeed S24rpcgssd S30vboxadd S95atd
K10saslauthd K60nfs K80sssd S01sysstat S13irqbalance S24rpcidmapd S30vboxadd-x11 S97rhnsd
K15httpd K69rpcsvcgssd K84wpa_supplicant S02lvm2-monitor S13rpcbind S25cups S35vboxadd-service S98tog-pegasus
K20tomcat6 K73ypbind K86cgred S08ip6tables S15mdmonitor S25netfs S50bluetooth S99local
K36mysqld K74nscd K87restorecond S08iptables S22messagebus S26acpid S55sshd
K50dnsmasq K74ntpd K88nslcd S10network S23NetworkManager S26haldaemon S80postfix

我们再来看看用户主目录下的.bashrc文件内容

 [root@localhost grub]# cat ~/.bashrc
# .bashrc # User specific aliases and functions alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i' # Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

我们再来看看用户主目录下的.bash_profile文件内容

 [root@localhost grub]# cat ~/.bash_profile
# .bash_profile # Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH

完整的流程图如下图:

[转] 浅谈Linux系统的启动流程的更多相关文章

  1. 浅谈Linux系统的启动流程

    Linux系统的启动时通过读取不同的配置文件,执行相应的Shell脚本完成的.当然本文只是简单的从文件的角度分析,更深层次的本文没涉及. 主要读取了以下文件:  /boot/grub/grub.con ...

  2. Linux系统的启动流程

    Linux系统的启动流程: 1.通电(通常按下电源键,开始通电) 2.加载BIOS (通常看到显示器提示按F2进入主板) 3.读取MBR (MBR硬盘的入口地址,用来装载引导) 4.进入引导 (通常有 ...

  3. linux系统的启动流程梳理

    1. 不同版本的linux系统的启动流程 1.1 centos6.x系统的启动流程 其详细启动步骤如下: 1)开机,BIOS自检,检查各个硬件是否正常 2)读取硬盘MBR信息,引导系统启动 3)加载g ...

  4. 2021年3月-第01阶段-Linux基础-Linux系统的启动流程

    Linux系统的启动流程 理解Linux操作系统启动流程,能有助于后期在企业中更好的维护Linux服务器,能快速定位系统问题,进而解决问题. 上图为Linux操作系统启动流程 1.加载BIOS 计算机 ...

  5. Linux系统的启动流程以及做个小小的Linux

    内核的作用     进程管理:进程间切换     内存管理:内存空间分割为内核空间和用户空间     IO管理:对底层硬件的使用必须由内来实现,不能由用户空间进程来实现     文件系统管理     ...

  6. Linux系统开机启动流程

    (来源学习Linux时,自己做的笔记) Linux系统有7个运行级别(runlevel)运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动运行级别1:单用户工作状态,root权限, ...

  7. 老司机浅谈linux系统学习技巧

    Linux起源于20世纪70年代,是一种优秀的操作系统系统.初次接触到linux这个系统是在大学期间,这样才发现除了windows外的另外一个有趣系统.开始抱着好奇的心态去了解,随着深入学习,笔者被它 ...

  8. 浅谈Linux系统中如何查看进程

    进程是一个其中运行着一个或多个线程的地址空间和这些线程所需要的系统资源.一般来说,Linux系统会在进程之间共享程序代码和系统函数库,所以在任何时刻内存中都只有代码的一份拷贝. 1,ps命令 作用:p ...

  9. 浅谈Linux系统中如何查看进程 ——ps,pstree,top,w,全解

    进程是一个其中运行着一个或多个线程的地址空间和这些线程所需要的系统资源.一般来说,Linux系统会在进程之间共享程序代码和系统函数库,所以在任何时刻内存中都只有代码的一份拷贝. 1,ps命令 作用:p ...

随机推荐

  1. Python使用split使用多个字符分隔字符串

    Python的str类有split方法,但是这个split方法只能根据指定的某个字符分隔字符串,如果要同时指定多个字符来分隔字符串,该怎么办呢? 幸运的是python的re模块中提供的split方法可 ...

  2. A trip through the Graphics Pipeline 2011_08_Pixel processing – “fork phase”

    In this part, I’ll be dealing with the first half of pixel processing: dispatch and actual pixel sha ...

  3. Vim ide for shell development

    Source : This article is part of the ongoing Vi / Vim Tips and Tricks Series. As a Linux sysadmin or ...

  4. 如何获取网页上的LOGO

    一般公司网页上的图片都会禁止右键另存为,用截图工具接下来的图会带背景色,PS成背景透明有点费时间. 用Google Chrome 或Firefox 打开目标网页,右键点击审查元素,将鼠标放在图片上,一 ...

  5. tomcat 设置集群

    本文介绍的是使用tomcat内置的集群功能.跟官方文档的区别是没有使用广播,而是使用了static membership的方式. 需要修改server.xml 放在哪个元素下来的,是Host还是啥记不 ...

  6. delphi关闭程序Close,application.Terminate与halt区别

    当Close是一个主窗体时,程序会退出.Close会发生FormClose事件,FormCloseQuery事件Halt会发生FormDestory事件,Application.Terminate以上 ...

  7. 修改git commit默认触发的编辑器

    使用git commit会自动启动编辑器编辑本次提交的comment,git默认配置是GNU nano,但是很多人不是很熟悉(我就是),其实这个是可以自行配置的. 编辑制定代码库的.git/confi ...

  8. Unity3D 装备系统学习Inventory Pro 2.1.2 总结

    前言 写在最前面,本文未必适合纯新手,但有一些C#开发经验的还是可以看懂的,虽然本人也是一位Unity3D新人,但是本文只是自己在学习Inventory Pro的学习总结,而不是教程,本人觉得要读懂理 ...

  9. 响应式布局2--MATE

    随着高端手机(Andriod,Iphone,Ipod,WinPhone等)的盛行,移动互联应用开发也越来越受到人们的重视,用html5开发移动应用是最好的选择.然而,每一款手机有不同的分辨率,不同屏幕 ...

  10. AJAX-----08jsonp跨域请求

    jsonp跨域请求其实我个人感觉并非传统上的ajax,因为传统的ajax几乎都是采用了xmlhttprequest这个对象来进行发送数据或者接收数据而已, 而jsop是通过双方约定成一个接口文件,然后 ...