Introduction to the Linux System Startup Process

Source: Internet
Author: User

When Linux is started, different configuration files are read and corresponding Shell scripts are executed. Of course, this article is just a simple analysis from the perspective of files, which is not involved in a deeper level.

The following files are read:

/Boot/grub. conf
/Etc/inittab
/Etc/rc5.d (rc. d) 0-99 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

Let's first look at the grub. conf file.

[Root @ www.bkjia.com grub] # ll menu. lst
Lrwxrwxrwx. 1 root 11 7o? = O? = 19 :52 menu. lst->./grub. conf
[Root @ www.bkjia.com grub] # pwd
/Boot/grub
Grub. conf file content:
Default = 0
Timeout = 5
Splashimage = (hd0, 0)/boot/grub/splash.xpm.gz
Hiddenmenu
Title Red Hat Enterprise Linux (2.6.32-220. el6.i686)
Root (hd0, 0)
Kernel/boot/vmlinuz-2.6.32-220.el6.i686 ro
Root = UUID = ed98469d-857b-4ae5-91e4-118e0167ead7 rd_NO_LUKS rd_NO_LVM
LANG = en_US.UTF-8 rd_NO_MD quiet SYSFONT = lat arcyrheb-sun16 (rhgb)
Crashkernel = auto KEYBOARDTYPE = pc KEYTABLE = us rd_NO_DM
Initrd/boot/initramfs-2.6.32-220.el6.i686.img

Run the runlevel command to check that the startup level is 5.

[Root @ www.bkjia.com grub] # runlevel

N 5

We enter the etc directory, and we can see a lot of rcX. d directories.

[Root @ www.bkjia.com grub] # cd/etc/init. d

[Root @ www.bkjia.com init. d] # cd/etc
[Root @ www.bkjia.com etc] # cd rc
Rc rc0.d/rc1.d/rc2.d/rc3.d/rc4.d/rc5.d/
Rc6.d/rc. d/rc. local rc. sysinit

We enter the/etc/profile. d directory, and we can see a lot of executable scripts.

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

Because the startup level is 5, we enter rc5.d and can see many files. S indicates that the file is executed when the system is started, and K indicates that the file is executed when the system is disabled.

[Root @ localhost grub] # ll/etc/rc5.d/
K01certmonger K50netconsole K75ntpdate K89rdisc S11auditd Co., 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

Let's take a look at the. bashrc file in the user's main directory.

[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

Let's take a look at the. bash_profile file in the user's main directory.

[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

The complete flowchart is as follows:

Recommended reading:

Describes the Linux Startup Process and the configuration files and scripts used for Linux Startup.

Notes on Linux Startup Process

How many mini systems does the Linux Startup Process know?

Linux Startup Process

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.