“ 本文正在参加「金石计划 . 瓜分6万现金大奖」 ”
6.4.2 /usr目录的重要知识介绍
6.4.2.1 /usr/local:编译安装软件默认的位置路径
这个目录一般是用来存放用户自编译安装软件的目录的,对于通过源码包安装的软件,如果没有特别指定安装目录的话,一般会安装在这个目录中,相当于Windows系统下的C:\Program Files。
6.4.2.2 /usr/src:存放源码文件的目录
这个目录一般被用来存放网上下载的软件源代码,当然了,这也是可选的,你可以根据需要进行更改。
6.4.3 /var目录下的路径知识
6.4.3.1 /var/log:记录系统及软件运行信息文件所在的目录
/var/log目录中包含了大量记录系统及软件服务运行的日志文件,通过这些日志文件,我们可以知道系统的运行情况及故障原因,其中典型的文本日志请参见表6-4。
表6-4 典型的日志文件列表
6.4.3.2 /var/log/messages:系统级别的日志文件
/var/log/messages是系统默认的日志文件,这个文件非常重要,当系统及软件遇到运行故障时,可以查看这个日志文件以获取故障信息,该文件按周自动轮循(一周来一刀,每周切割一次)。示例代码如下:
[root@centos7 ~]# ll /var/log/messages*
-rw-------. 1 root root 128458 Oct 8 15:20 /var/log/messages
-rw-------. 1 root root 2272408 Oct 8 13:17 /var/log/messages-20201008
[root@centos7 ~]# tail -n 5 /var/log/messages
Oct 8 15:00:01 oldboy systemd: Started Session 7 of user root.
Oct 8 15:01:01 oldboy systemd: Started Session 8 of user root.
Oct 8 15:10:01 oldboy systemd: Started Session 9 of user root.
Oct 8 15:20:01 oldboy systemd: Started Session 10 of user root.
Oct 8 15:30:01 oldboy systemd: Started Session 11 of user root.
上述轮循日志由/etc/logrotate.conf和/etc/logrotate.d/syslog控制。
#CentOS 7
[root@centos7 ~]# ll /etc/logrotate.conf
-rw-r--r--. 1 root root 662 Jul 31 2013 /etc/logrotate.conf
[root@centos7 ~]# cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
dateext
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
[root@centos7 ~]# ll /etc/logrotate.d/syslog
-rw-r--r--. 1 root root 224 Nov 28 2019 /etc/logrotate.d/syslog
[root@centos7 ~]# cat /etc/logrotate.d/syslog
/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
missingok
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
#CentOS 6
[root@centos6 ~]# ll /etc/logrotate.conf
-rw-r--r--. 1 root root 662 Aug 29 2007 /etc/logrotate.conf
[root@centos6 ~]# cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
dateext
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
[root@centos6 ~]# ll /etc/logrotate.d/syslog
-rw-r--r--. 1 root root 210 Dec 10 2014 /etc/logrotate.d/syslog
[root@centos6 ~]# cat /etc/logrotate.d/syslog
/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
6.4.3.3 /var/log/secure:用户登录信息日志文件
这是一个有关系统安全的日志文件,日志中会记录“谁,在干什么,从哪登录到系统,登录是否成功“等信息。ssh、telnet、ftp等服务的用户登录信息都会记录在此。示例代码如下:
[root@centos7 ~]# tail -n 5 /var/log/secure
Oct 8 14:35:37 oldboy login: pam_unix(login:auth): authentication failure; logname=LOGIN uid=0 euid=0 tty=tty1 ruser= rhost= user=root
Oct 8 14:35:37 oldboy login: pam_succeed_if(login:auth): requirement "uid >= 1000" not met by user "root"
Oct 8 14:35:39 oldboy login: FAILED LOGIN 1 FROM tty1 FOR root, Authentication failure
Oct 8 14:35:45 oldboy login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)
Oct 8 14:35:45 oldboy login: ROOT LOGIN ON tty1
该文件与messages文件一样,也是按周自动轮循的。示例代码如下:
[root@centos7 ~]# ll /var/log/secure*
-rw-------. 1 root root 3921 Oct 8 14:35 /var/log/secure
-rw-------. 1 root root 36582 Oct 8 13:07 /var/log/secure-20201008
6.4.3.4 /var/log/dmesg:记录硬件信息加载的日志文件
当应急及系统内核出现问题时,可以查看这个日志文件,在解决问题时没准会有额外的收获,读者也可以通过dmesg命令来收集相关信息,为能读懂的人提供解决问题的依据。示例代码如下:
[root@centos7 ~]# dmesg > oldboy.log
[root@centos7 ~]# tail -5 oldboy.log
[ 31.322065] NET: Registered protocol family 40
[ 34.750974] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 34.757044] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[ 34.763032] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 34.763059] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
#提示:系统开机加载完硬件后,会执行dmesg将信息输入到/var/log/dmesg中。
[root@centos7 ~]# ll /var/log/dmesg*
-rw-r--r--. 1 root root 121765 Oct 8 14:16 /var/log/dmesg
-rw-r--r--. 1 root root 121866 Oct 8 12:59 /var/log/dmesg.old
[root@centos7 ~]# tail -n 5 /var/log/dmesg
[ 7.625276] AMD64 EDAC driver v3.4.0
[ 8.816487] XFS (sda1): Ending clean mount
[ 9.360081] type=1305 audit(1602137802.732:4): audit_pid=787 old=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:auditd_t:s0 res=1
[ 9.785450] floppy0: no floppy controllers found
[ 9.785512] work still pending
6.4.4 /proc下的重要路径知识
/proc是Linux系统下的一个重要的虚拟文件系统,记录着内核和进程方方面面的信息,它是一个很重要的信息宝库,表6-5是最常用的信息文件列表。
表6-5 /proc常用的信息文件列表
查看CPU信息:
[root@centos7 ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
stepping : 9
microcode : 0x48
cpu MHz : 3408.040
cache size : 6144 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec arat
bogomips : 6816.08
clflush size : 64
cache_alignment : 64
address sizes : 43 bits physical, 48 bits virtual
power management:
查看内存信息:
[root@centos7 ~]# cat /proc/meminfo
MemTotal: 1863012 kB
MemFree: 1600716 kB
MemAvailable: 1584748 kB
Buffers: 2076 kB
Cached: 106304 kB
SwapCached: 0 kB
Active: 77240 kB
Inactive: 77200 kB
Active(anon): 46472 kB
Inactive(anon): 9288 kB
Active(file): 30768 kB
Inactive(file): 67912 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 786428 kB
SwapFree: 786428 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 46144 kB
Mapped: 25664 kB
Shmem: 9700 kB
Slab: 52644 kB
SReclaimable: 18932 kB
SUnreclaim: 33712 kB
KernelStack: 3808 kB
PageTables: 3960 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1717932 kB
Committed_AS: 235340 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 178896 kB
VmallocChunk: 34359310332 kB
Percpu: 22528 kB
HardwareCorrupted: 0 kB
AnonHugePages: 6144 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 59264 kB
DirectMap2M: 2037760 kB
DirectMap1G: 0 kB
#free命令,查看内存使用信息
[root@centos7 ~]# free
total used free shared buff/cache available
Mem: 1863012 133156 1599184 9732 130672 1584880
Swap: 786428 0 786428
[root@centos7 ~]# free -m
total used free shared buff/cache available
Mem: 1819 130 1561 9 127 1547
Swap: 767 0 767
[root@centos7 ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 130M 1.5G 9.5M 127M 1.5G
Swap: 767M 0B 767M
查看系统平均负载:
[root@centos7 ~]# cat /proc/loadavg
0.00 0.01 0.05 2/109 1877
#uptime命令,查看系统登录时间、登录多久、登录几个用户、平均负载等信息
[root@centos7 ~]# uptime
15:47:14 up 1:30, 2 users, load average: 0.00, 0.01, 0.05
#当前时间 开机多久时间 登录几个用户 负载 平均 1分钟 5分钟 15分钟
#负载的数字和CPU核数相当的时候就是负载一个临界点,例如 一颗两核 临界负载就是2
[root@centos7 ~]# who
root tty1 2020-10-08 14:35
root pts/0 2020-10-08 14:16 (10.0.0.1)
#who命令,查看哪些用户在哪些终端登录
[root@centos7 ~]# whoami
root
#whoami命令,查看当前终端登录的用户
[root@centos7 ~]# w
16:00:14 up 1:43, 2 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 14:35 1:24m 0.04s 0.04s -bash
root pts/0 10.0.0.1 14:16 6.00s 0.26s 0.06s w
#w命令,查看系统登录时间、登录多久、登录几个用户、平均负载、哪些用户在哪个终端登录、登录IP、登录时间、执行什么命令等信息
查看当前设备挂载列表信息
[root@centos7 ~]# cat /proc/mounts
rootfs / rootfs rw 0 0
sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=920904k,nr_inodes=230226,mode=755 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev 0 0
devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,seclabel,nosuid,nodev,mode=755 0 0
tmpfs /sys/fs/cgroup tmpfs ro,seclabel,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,seclabel,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,seclabel,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,seclabel,nosuid,nodev,noexec,relatime,cpuacct,cpu 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,seclabel,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,seclabel,nosuid,nodev,noexec,relatime,net_prio,net_cls 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,seclabel,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,seclabel,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,seclabel,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/hugetlb cgroup rw,seclabel,nosuid,nodev,noexec,relatime,hugetlb 0 0
cgroup /sys/fs/cgroup/pids cgroup rw,seclabel,nosuid,nodev,noexec,relatime,pids 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,seclabel,nosuid,nodev,noexec,relatime,memory 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
/dev/sda3 / xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime 0 0
mqueue /dev/mqueue mqueue rw,seclabel,relatime 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=32,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13621 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
/dev/sda1 /boot xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
tmpfs /run/user/0 tmpfs rw,seclabel,nosuid,nodev,relatime,size=186304k,mode=700 0 0
查看当前系统中断信息
[root@centos7 ~]# cat /proc/interrupts
CPU0
0: 49 IO-APIC-edge timer
1: 102 IO-APIC-edge i8042
8: 1 IO-APIC-edge rtc0
9: 0 IO-APIC-fasteoi acpi
12: 1021 IO-APIC-edge i8042
14: 0 IO-APIC-edge ata_piix
15: 6639 IO-APIC-edge ata_piix
16: 4970 IO-APIC-fasteoi vmwgfx, snd_ens1371
17: 8284 IO-APIC-fasteoi ehci_hcd:usb1, ioc0
18: 66 IO-APIC-fasteoi uhci_hcd:usb2
19: 6349 IO-APIC-fasteoi eth0
24: 0 PCI-MSI-edge PCIe PME, pciehp
25: 0 PCI-MSI-edge PCIe PME, pciehp
26: 0 PCI-MSI-edge PCIe PME, pciehp
27: 0 PCI-MSI-edge PCIe PME, pciehp
28: 0 PCI-MSI-edge PCIe PME, pciehp
29: 0 PCI-MSI-edge PCIe PME, pciehp
30: 0 PCI-MSI-edge PCIe PME, pciehp
31: 0 PCI-MSI-edge PCIe PME, pciehp
32: 0 PCI-MSI-edge PCIe PME, pciehp
33: 0 PCI-MSI-edge PCIe PME, pciehp
34: 0 PCI-MSI-edge PCIe PME, pciehp
35: 0 PCI-MSI-edge PCIe PME, pciehp
36: 0 PCI-MSI-edge PCIe PME, pciehp
37: 0 PCI-MSI-edge PCIe PME, pciehp
38: 0 PCI-MSI-edge PCIe PME, pciehp
39: 0 PCI-MSI-edge PCIe PME, pciehp
40: 0 PCI-MSI-edge PCIe PME, pciehp
41: 0 PCI-MSI-edge PCIe PME, pciehp
42: 0 PCI-MSI-edge PCIe PME, pciehp
43: 0 PCI-MSI-edge PCIe PME, pciehp
44: 0 PCI-MSI-edge PCIe PME, pciehp
45: 0 PCI-MSI-edge PCIe PME, pciehp
46: 0 PCI-MSI-edge PCIe PME, pciehp
47: 0 PCI-MSI-edge PCIe PME, pciehp
48: 0 PCI-MSI-edge PCIe PME, pciehp
49: 0 PCI-MSI-edge PCIe PME, pciehp
50: 0 PCI-MSI-edge PCIe PME, pciehp
51: 0 PCI-MSI-edge PCIe PME, pciehp
52: 0 PCI-MSI-edge PCIe PME, pciehp
53: 0 PCI-MSI-edge PCIe PME, pciehp
54: 0 PCI-MSI-edge PCIe PME, pciehp
55: 0 PCI-MSI-edge PCIe PME, pciehp
56: 829 PCI-MSI-edge vmw_vmci
57: 0 PCI-MSI-edge vmw_vmci
NMI: 3 Non-maskable interrupts
LOC: 213769 Local timer interrupts
SPU: 0 Spurious interrupts
PMI: 3 Performance monitoring interrupts
IWI: 9966 IRQ work interrupts
RTR: 0 APIC ICR read retries
RES: 0 Rescheduling interrupts
CAL: 0 Function call interrupts
TLB: 0 TLB shootdowns
TRM: 0 Thermal event interrupts
THR: 0 Threshold APIC interrupts
DFR: 0 Deferred Error APIC interrupts
MCE: 0 Machine check exceptions
MCP: 23 Machine check polls
ERR: 0
MIS: 0
PIN: 0 Posted-interrupt notification event
NPI: 0 Nested posted-interrupt event
PIW: 0 Posted-interrupt wakeup event
6.5 Linux (CentOS 6)系统启动流程说明(重点)
系统管理员需要理解Linux系统的启动流程,这样才能对系统启动时出现的异常进行快速排查。在企业面试时,经常会有面试官让面试者描述Linux的启动流程细节,基于此,下面笔者就为大家简要介绍下Linux系统的启动流程,读者掌握本节的内容就够了,无须过多细陷入无用知识的泥潭。
第一步:开启开机按钮,计算机加载BIOS自检。
打开计算机电源,计算机首先会加载BIOS(主板上的一块芯片,第0章已经讲解过了)信息,进而对CPU信息、设备启动顺序信息、硬盘信息、内存信息、时钟信息等进行自检。当正确检查完所有硬件信息后,计算机就会根据BIOS里的设置去读取相应的启动系统里的硬件设备,如果预先设定了从硬盘启动加载系统,那么BIOS就会读取硬盘的MBR(即0磁道0柱面1扇区的前446字节),接下来才开始加载内核文件,然后交由Linux来控制系统运行。相关的图解如图6-10和图6-10所示。
图6-10 计算机电源按钮
图6-11 计算机BIOS管理界面
第二步:读取MBR信息。
MBR全称为Master Boot Record,中文的意思是主引导记录,它位于磁盘上的0柱面0磁道1扇区,整个大小是512字节,MBR里面存放了系统预启动信息、分区表信息及分区标志等。
在MBR的512字节中,第一部分为引导记录区,占有前446字节大小,其作用是找到标记为活动的分区,并将活动分区的引导记录读入内存。
第二部分为分区表,占有后面剩下全部的66字节大小,用于记录磁盘的分区信息,这其中,前64字节是磁盘分区表信息,后2字节是分区的结束标志(后文会详解磁盘分区表)。
计算机读取BIOS所制定的磁盘MBR信息之后,就会将其读入到内存中。被读入到内存中执行的其实就是Boot Loader(引导加载程序),对应于Linux系统,就是加载Grub信息。
第三步:加载Grub菜单(Boot Loader,引导加载程序)。
引导加载程序(Boot Loader)是计算机在加载操作系统内核之前运行的一段小程序。这段小程序可以初始化硬件设备、建立内存空间的映射图,从而将系统的软硬件环境加载到一个适合的状态,以便最终调用操作系统内核做好准备。通常,引导加载的程序依赖于硬件实现,早期的Linux系统常见的引导加载程序包含2中,即Grub和Lilo,现如今Grub已经成为了主流(类似于Windows下的boot.ini引导文件)。
引导加载程序读取grub.conf文件的配置信息,然后根据对应的配置信息来启动不同的操作系统,grub.conf的配置信息及详解如下所示:
[root@centos6 ~]# ll /etc/grub.conf /boot/grub/menu.lst /boot/grub/grub.conf-rw-------. 1 root root 745 9月 14 02:33 /boot/grub/grub.conf
lrwxrwxrwx. 1 root root 11 9月 14 02:33 /boot/grub/menu.lst -> ./grub.conf
lrwxrwxrwx. 1 root root 22 9月 14 02:33 /etc/grub.conf -> ../boot/grub/grub.conf
[root@centos6 ~]# cat /etc/grub.conf #也可读取/boot/grub/menu.lst或/boot/grub/grub.conf。
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda5
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0 #默认情况下如何加载系统,0表示加载菜单中对应的第一个名字,多系统时可以调节默认加载项。
timeout=5 #表示多少秒之后开始加载默认的系统,为管理员提前选择留出时间。
splashimage=(hd0,0)/grub/splash.xpm.gz #启动时显示的背景图片,(hd0,0)代表/boot分区。
hiddenmenu #系统启动时,会隐藏启动菜单信息,按默认设置即可启动系统,除非用户按键干预。
password [-md5]-encrypted ] STRING #编辑Grub菜单时需要认证,Linux优化之一,默认为没有。
title CentOS 6 (2.6.32-642.el6.x86_64) #要启动的系统对应的项目名称,可按需修改。
root (hd0,0) #引导内核文件和内核所需驱动文件所在的分区,(hd0,0)代表/boot分区。
#其中hd0表示计算机的第一块磁盘,(hd0,0)中逗号后面的0表示第一个分区,即(hd0,0)表示第一块磁盘的第一个分区,即/dev/sda1(分区通常是最先独立分出的/boot分区,对应的设备名就是sda1).
kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=UUID=bbbdb908-d86c-466b-ada6-0dbf80f1419d rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet #位于boot分区上的内核文件,及一堆可选内核参数。
#/vmlinuz-2.6.32-642.el6.x86_64为内核文件。root=UUID=后面一串数字表示根对应的设备信息(/dev/sda3),其他介绍作用不大,忽略即可。
initrd /initramfs-2.6.32-642.el6.x86_64.img #内核启动所需的驱动文件的所在地,存在于boot区。
提示:grub.conf的知识其实在企业Linux运维中用途不是很大,这里讲解Grub的目的是,希望能为读者了解Linux系统的整个启动流程做铺垫,RHCE认证课程会有修复grub.conf的考题,其实没什么大用,因为在IT网站的运维工作中,极少会在线处理问题,除了问题也是直接切换服务了,之后再来慢慢研究是修复还是重装。
加载Grub菜单的过程中,如果按Esc键,即可停在原来处于隐藏状态下的Grub菜单中,如图6-12所示。
图6-12 Grub启动菜单
菜单中只有一个选项,底下的小字表示可以做一些特殊的设置,例如,设置内核参数、加载单用户模式等。随便设置加载Grub启动参数也是会存在安全隐患的,因此,工作中可以为Grub添加密码以将其锁定(见后文Linux系统基础优化部分)。
第四步:加载kernel内核以及驱动程序。
根据Grub设定的内核映像所在的路径,系统会读取内存映像,并进行解压缩操作。完成解压缩内核之后,屏幕会输出“OK,booting the kernel”的信息。其实就是根据grub.conf中的如下设置加载内核及相关参数:
kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=UUID=bbbdb908-d86c-466b-ada6-0dbf80f1419d rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
此外,还会加载内核所需的驱动程序文件,进而挂载并读取根分区的信息,加载操作系统文件。示例代码如下:
initrd /initramfs-2.6.32-642.el6.x86_64.img
第五步:启动init进程,读取inittab文件。
加载完内核的相关文件以后,系统第一个运行的程序为/sbin/init,因此,init进程对应的进程号永远为1,相当于是所有Linux进程的祖先。
[root@centos6 ~]# ps -ef |grep init
root 1 0 0 Oct08 ? 00:00:01 /sbin/init
root 2316 1739 0 00:54 pts/0 00:00:00 grep init
此时init程序会读取/etc/inittab文件,并依据此文件来进行初始化工作。其实CentOS 6以来的/etc/inittab文件最主要的作用就是设定了Linux以什么样的运行等级启动,其设定配置是"id:3:initdefault:",其中的3就是表明Linux需要运行在3级别上,更多运行级别上文已经讲解过。
第六步:init进程执行rc.sysinit初始化系统。
在CentOS 6以前的版本中,init进程会根据inittab的设置加载/etc/rc.d/rc.sysinit,并进行初始化,系统设置包括但不限于如下内容。
设置主机名、设置欢迎信息、激活udev和selinux、加载/etc/fstab(挂载磁盘设备等)、设置系统时钟、读取/etc/sysctl.conf设置内核参数、激活lvm及sofrware raid设备、加载额外设备的驱动程序、各种清理操作(如清理日志)等。
有兴趣的读者可以浏览/etc/rc.d/rc.sysinit文件查看细节。
CentOS 6以后,init进程不再读取inittab加载/etc/rc.d/rc.sysinit了,而是读取/etc/init/rcS.conf文件加载/etc/rc.d/rc.sysinit,并对系统进行初始化系统设置,网上的文章大多数讲的还是CentOS 6以前的加载方式,在开机过程中按Esc键可以看到,rc.sysinit脚本初始化硬件系统的执行过程如图6-13所示。
[root@centos6 ~]# ll /etc/init/rcS.conf
-rw-r--r--. 1 root root 1046 Apr 12 2016 /etc/init/rcS.conf
[root@centos6 ~]# cat /etc/init/rcS.conf
# rcS - runlevel compatibility
#
# This task runs the old sysv-rc startup scripts.
#
# Do not edit this file directly. If you want to change the behaviour,
# please create a file rcS.override and put your changes there.
start on startup
stop on runlevel
task
# Note: there can be no previous runlevel here, if we have one it's bad
# information (we enter rc1 not rcS for maintenance). Run /etc/rc.d/rc
# without information so that it defaults to previous=N runlevel=S.
console output
pre-start script
for t in $(cat /proc/cmdline); do
case $t in
emergency)
start rcS-emergency
break
;;
esac
done
end script
exec /etc/rc.d/rc.sysinit
post-stop script
if [ "$UPSTART_EVENTS" = "startup" ]; then
[ -f /etc/inittab ] && runlevel=$(/bin/awk -F ':' '$3 == "initdefault" && $1 !~ "^#" { print $2 }' /etc/inittab)
[ -z "$runlevel" ] && runlevel="3"
for t in $(cat /proc/cmdline); do
case $t in
-s|single|S|s) runlevel="S" ;;
[1-9]) runlevel="$t" ;;
esac
done
exec telinit $runlevel
fi
end script
[root@centos6 ~]# ll /etc/rc.d/rc.sysinit
-rwxr-xr-x. 1 root root 20199 May 12 2016 /etc/rc.d/rc.sysinit
第七步:init进程加载内核相关模块。
CentOS 5下是读取/etc/modules.conf文件或/etc/modules.d目录下的文件来加载内核模块,而在CentOS 6下则是加载/etc/sysconfig/modules/下的内核模块。如果6-13中结尾的一行就是加载内核的相关信息。
第八步:init进程执行对应运行级别下的脚本。
根据系统设定运行级别的不同,系统会运行rc0.d到rc6.d中的相应脚本程序,从而完成相应的初始化工作,以及启动相应的服务。
图6-13 rc.sysinit脚本初始化硬件信息的执行过程
需要特别说明的是,在CentOS 6以后的版本中,init进程不再读取inittab 加载运行级别对应的脚本了,而是读取/etc/init/tc.conf加载指定运行级别下的脚本,对应运行级别的脚本目录如下所示:
[root@centos6 ~]# ll /etc/rc.d
total 60
drwxr-xr-x. 2 root root 4096 Sep 14 02:32 init.d
-rwxr-xr-x. 1 root root 2617 May 12 2016 rc
drwxr-xr-x. 2 root root 4096 Sep 14 02:32 rc0.d
#0运行级别对应的脚本目录。
drwxr-xr-x. 2 root root 4096 Sep 14 02:32 rc1.d
#1运行级别对应的脚本目录。
drwxr-xr-x. 2 root root 4096 Sep 14 02:32 rc2.d
#2运行级别对应的脚本目录。
drwxr-xr-x. 2 root root 4096 Sep 14 02:32 rc3.d
#3运行级别对应的脚本目录。
drwxr-xr-x. 2 root root 4096 Sep 14 02:32 rc4.d
#4运行级别对应的脚本目录。
drwxr-xr-x. 2 root root 4096 Sep 14 02:32 rc5.d
#5运行级别对应的脚本目录。
drwxr-xr-x. 2 root root 4096 Sep 14 02:32 rc6.d
#6运行级别对应的脚本目录。
-rwxr-xr-x. 1 root root 220 May 12 2016 rc.local
#开机自启动程序配置文件。
-rwxr-xr-x. 1 root root 20199 May 12 2016 rc.sysinit
#初始化系统脚本。
加载/etc/rc.d/rc3.d下的文件
[root@centos6 ~]# ll /etc/rc.d/rc3.d
total 0
lrwxrwxrwx. 1 root root 15 Sep 14 02:31 K01numad -> ../init.d/numad
lrwxrwxrwx. 1 root root 16 Sep 14 02:31 K01smartd -> ../init.d/smartd
lrwxrwxrwx. 1 root root 17 Sep 14 02:29 K02oddjobd -> ../init.d/oddjobd
lrwxrwxrwx. 1 root root 16 Sep 14 02:32 K10psacct -> ../init.d/psacct
lrwxrwxrwx. 1 root root 19 Sep 14 02:29 K10saslauthd -> ../init.d/saslauthd
lrwxrwxrwx. 1 root root 13 Sep 14 02:29 K60nfs -> ../init.d/nfs
lrwxrwxrwx. 1 root root 18 Sep 14 02:31 K61nfs-rdma -> ../init.d/nfs-rdma
lrwxrwxrwx. 1 root root 20 Sep 14 02:29 K69rpcsvcgssd -> ../init.d/rpcsvcgssd
lrwxrwxrwx. 1 root root 17 Sep 14 02:29 K73winbind -> ../init.d/winbind
lrwxrwxrwx. 1 root root 14 Sep 14 02:29 K74ntpd -> ../init.d/ntpd
lrwxrwxrwx. 1 root root 18 Sep 14 02:29 K75cgconfig -> ../init.d/cgconfig
lrwxrwxrwx. 1 root root 17 Sep 14 02:29 K75ntpdate -> ../init.d/ntpdate
lrwxrwxrwx. 1 root root 19 Sep 14 02:31 K75quota_nld -> ../init.d/quota_nld
lrwxrwxrwx. 1 root root 16 Sep 14 02:29 K76ypbind -> ../init.d/ypbind
lrwxrwxrwx. 1 root root 15 Sep 14 02:29 K86cgred -> ../init.d/cgred
lrwxrwxrwx. 1 root root 21 Sep 14 02:29 K87restorecond -> ../init.d/restorecond
lrwxrwxrwx. 1 root root 14 Sep 14 02:29 K88sssd -> ../init.d/sssd
lrwxrwxrwx. 1 root root 20 Sep 14 02:29 K89netconsole -> ../init.d/netconsole
lrwxrwxrwx. 1 root root 15 Sep 14 02:29 K89rdisc -> ../init.d/rdisc
lrwxrwxrwx. 1 root root 14 Sep 14 02:31 K95rdma -> ../init.d/rdma
lrwxrwxrwx. 1 root root 14 Sep 14 02:31 K99rngd -> ../init.d/rngd
lrwxrwxrwx. 1 root root 17 Sep 14 02:31 S01sysstat -> ../init.d/sysstat
lrwxrwxrwx. 1 root root 22 Sep 14 02:31 S02lvm2-monitor -> ../init.d/lvm2-monitor
lrwxrwxrwx. 1 root root 19 Sep 14 02:30 S08ip6tables -> ../init.d/ip6tables
lrwxrwxrwx. 1 root root 18 Sep 14 02:29 S08iptables -> ../init.d/iptables
lrwxrwxrwx. 1 root root 17 Sep 14 02:29 S10network -> ../init.d/network
lrwxrwxrwx. 1 root root 16 Sep 14 02:32 S11auditd -> ../init.d/auditd
lrwxrwxrwx. 1 root root 21 Sep 14 02:26 S11portreserve -> ../init.d/portreserve
lrwxrwxrwx. 1 root root 17 Sep 14 02:29 S12rsyslog -> ../init.d/rsyslog
lrwxrwxrwx. 1 root root 18 Sep 14 02:31 S13cpuspeed -> ../init.d/cpuspeed
lrwxrwxrwx. 1 root root 20 Sep 14 02:30 S13irqbalance -> ../init.d/irqbalance
lrwxrwxrwx. 1 root root 17 Sep 14 02:27 S13rpcbind -> ../init.d/rpcbind
lrwxrwxrwx. 1 root root 17 Sep 14 02:29 S14nfslock -> ../init.d/nfslock
lrwxrwxrwx. 1 root root 19 Sep 14 02:29 S15mdmonitor -> ../init.d/mdmonitor
lrwxrwxrwx. 1 root root 17 Sep 14 02:29 S19rpcgssd -> ../init.d/rpcgssd
lrwxrwxrwx. 1 root root 20 Sep 14 02:27 S22messagebus -> ../init.d/messagebus
lrwxrwxrwx. 1 root root 26 Sep 14 02:31 S25blk-availability -> ../init.d/blk-availability
lrwxrwxrwx. 1 root root 14 Sep 14 02:29 S25cups -> ../init.d/cups
lrwxrwxrwx. 1 root root 15 Sep 14 02:29 S25netfs -> ../init.d/netfs
lrwxrwxrwx. 1 root root 15 Sep 14 02:31 S26acpid -> ../init.d/acpid
lrwxrwxrwx. 1 root root 19 Sep 14 02:29 S26haldaemon -> ../init.d/haldaemon
lrwxrwxrwx. 1 root root 19 Sep 14 02:29 S26udev-post -> ../init.d/udev-post
lrwxrwxrwx. 1 root root 16 Sep 14 02:30 S28autofs -> ../init.d/autofs
lrwxrwxrwx. 1 root root 15 Sep 14 02:31 S50kdump -> ../init.d/kdump
lrwxrwxrwx. 1 root root 17 Sep 14 02:32 S50mcelogd -> ../init.d/mcelogd
lrwxrwxrwx. 1 root root 14 Sep 14 02:31 S55sshd -> ../init.d/sshd
lrwxrwxrwx. 1 root root 17 Sep 14 02:29 S80postfix -> ../init.d/postfix
lrwxrwxrwx. 1 root root 19 Sep 14 02:28 S82abrt-ccpp -> ../init.d/abrt-ccpp
lrwxrwxrwx. 1 root root 15 Sep 14 02:28 S82abrtd -> ../init.d/abrtd
lrwxrwxrwx. 1 root root 15 Sep 14 02:29 S90crond -> ../init.d/crond
lrwxrwxrwx. 1 root root 13 Sep 14 02:29 S95atd -> ../init.d/atd
lrwxrwxrwx. 1 root root 20 Sep 14 02:29 S99certmonger -> ../init.d/certmonger
lrwxrwxrwx. 1 root root 11 Sep 14 02:29 S99local -> ../rc.local
在开机过程中按Esc键,也可以看到系统根据运行级别加载对应运行级别下脚本的执行过程,如图6-14所示。
图6-14 根据运行级别加载对应运行级别下脚本执行过程图
第九步:加载/etc/rc.local。
/etc/rc.local就是在系统做好一切初始化工作之后,留给管理员自主设置的一个文件。可以将需要跟随计算机启动的程序启动命令放置到这里。
[root@centos6 ~]# ll /etc/rc.local
lrwxrwxrwx. 1 root root 13 Sep 14 02:29 /etc/rc.local -> rc.d/rc.local
[root@centos6 ~]# cat /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
第十步:启动mingetty,进入登录前的状态。
系统读取/etc/init/tty.conf(早期也是读取inittab进行设置的),设置对应运行级别的终端,启动mingetty,进入登录前的状态,如图6-15所示。
图6-15 登录前的界面
[root@centos6 ~]# ll /etc/init/tty.conf
-rw-r--r--. 1 root root 335 Apr 12 2016 /etc/init/tty.conf
[root@centos6 ~]# cat /etc/init/tty.conf
# tty - getty
#
# This service maintains a getty on the specified device.
#
# Do not edit this file directly. If you want to change the behaviour,
# please create a file tty.override and put your changes there.
stop on runlevel [S016]
respawn
instance $TTY
exec /sbin/mingetty $TTY
usage 'tty TTY=/dev/ttyX - where X is console id'
此时,输入用户及密码即可登录Linux系统,整个启动过程中的完整图解如图6-16所示。
图6-16 Linux启动流程图解(CentOS 6)
6.6 Linux (CentOS 7)系统启动流程说明(重点)
CentOS 7和CentOS 6的启动流程绝大部分还是相同的,但也有一些小区别,例如CentOS 6下第一个启动的init进程被改为了systemd(并行启动模式),下面重点说一下CentOS 7加载systemd进程后的启动流程,即从CentOS 6启动流程的第五步开始讲起,前四步与CentOS 6启动流程的描述一致。
CentOS 7的grub配置文件
[root@centos7 ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto biosdevname=0 net.ifnames=0 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
第五步:启动systemd进程,加载如下文件。
1)执行initrd.target(/usr/lib/systemd/system/initrd.target)包含挂载/etc/fstab文件中的文件系统。
[root@centos7 ~]# ll /usr/lib/systemd/system/initrd.target
-rw-r--r--. 1 root root 671 Aug 7 01:30 /usr/lib/systemd/system/initrd.target
[root@oldboy ~]# cat /usr/lib/systemd/system/initrd.target
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Initrd Default Target
Documentation=man:systemd.special(7)
OnFailure=emergency.target
OnFailureJobMode=replace-irreversibly
ConditionPathExists=/etc/initrd-release
Requires=basic.target
Wants=initrd-root-fs.target initrd-fs.target initrd-parse-etc.service
After=initrd-root-fs.target initrd-fs.target basic.target rescue.service rescue.target
AllowIsolate=yes
2)systemd执行默认的target配置。
CentOS 7已经淡化了CentOS 6的运行级别概念,但是为了兼容6以前的用户习惯,仍然以运行级别文件来进行标记,并且每个运行级别文件都有相应的软链接指向,默认的启动文件是/etc/systemd/system/default.target,根据它的指向可以找到系统要进入哪个模式。
[root@centos7 ~]# ll /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 41 Oct 7 16:29 /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target
[root@centos7 ~]# cat /usr/lib/systemd/system/multi-user.target
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Multi-User System
Documentation=man:systemd.special(7)
Requires=basic.target
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes
早期的7中运行级别对应于5个启动模式:
runlevel0.target -> poweroff.target
runlevel1.target -> rescue.target
runlevel2.target -> multi-user.target
runlevel3.target -> multi-user.target
runlevel4.target -> multi-user.target
runlevel5.target -> graphical.target
runlevel6.target -> reboot.target
[root@centos7 ~]# ll /usr/lib/systemd/system | grep level |grep -v want
lrwxrwxrwx. 1 root root 15 Oct 1 16:04 runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 Oct 1 16:04 runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 17 Oct 1 16:04 runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Oct 1 16:04 runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Oct 1 16:04 runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 Oct 1 16:04 runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 Oct 1 16:04 runlevel6.target -> reboot.target
-rw-r--r--. 1 root root 761 Aug 7 01:30 systemd-update-utmp-runlevel.service
3)systemd执行sysinit.target,初始化系统及加载basic.target准备启动系统。
[root@centos7 ~]# ll /usr/lib/systemd/system/sysinit.target
-rw-r--r--. 1 root root 518 Aug 7 01:30 /usr/lib/systemd/system/sysinit.target
[root@centos7 ~]# cat /usr/lib/systemd/system/sysinit.target
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=System Initialization
Documentation=man:systemd.special(7)
Conflicts=emergency.service emergency.target
Wants=local-fs.target swap.target
After=local-fs.target swap.target emergency.service emergency.target
[root@centos7 ~]# ll /usr/lib/systemd/system/basic.target /usr/lib/systemd/user/basic.target
-rw-r--r--. 1 root root 517 Aug 7 01:30 /usr/lib/systemd/system/basic.target
-rw-r--r--. 1 root root 457 Aug 7 01:30 /usr/lib/systemd/user/basic.target
[root@centos7 ~]# cat /usr/lib/systemd/system/basic.target
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Basic System
Documentation=man:systemd.special(7)
Requires=sysinit.target
After=sysinit.target
Wants=sockets.target timers.target paths.target slices.target
After=sockets.target paths.target slices.target
[root@oldboy ~]# cat /usr/lib/systemd/user/basic.target
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Basic System
Documentation=man:systemd.special(7)
Wants=sockets.target timers.target paths.target
After=sockets.target timers.target paths.target
4)systemd启动multi-user.target(生产工作模式)下的服务程序,即开机自启动的程序,程序目录为/etc/systemd/system和/usr/lib/systemd/system。
[root@centos7 ~]# ll -d /etc/systemd/system /usr/lib/systemd/system
drwxr-xr-x. 11 root root 4096 Oct 7 16:29 /etc/systemd/system
drwxr-xr-x. 25 root root 12288 Oct 1 16:17 /usr/lib/systemd/system
5)systemd执行multi-user.target下的/etc/rc.d/rc.local内容。
[root@centos7 ~]# ll /etc/rc.d/rc.local
-rw-r--r--. 1 root root 473 Aug 7 01:30 /etc/rc.d/rc.local
[root@centos7 ~]# cat /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
6)systemd执行multi-user.target下的getty.target及登录服务。
[root@centos7 ~]# ll /usr/lib/systemd/system/multi-user.target.wants/getty.target /usr/lib/systemd/system/getty.target
-rw-r--r--. 1 root root 460 Aug 7 01:30 /usr/lib/systemd/system/getty.target
lrwxrwxrwx. 1 root root 15 Oct 1 16:04 /usr/lib/systemd/system/multi-user.target.wants/getty.target -> ../getty.target
[root@centos7 ~]# cat /usr/lib/systemd/system/getty.target
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Login Prompts
Documentation=man:systemd.special(7) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
7)systemd执行graphical所需的服务(如果安装了图形桌面功能)。
[root@centos7 ~]# cat /usr/lib/systemd/system/graphical.target
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Graphical Interface
Documentation=man:systemd.special(7)
Requires=multi-user.target
Wants=display-manager.service
Conflicts=rescue.service rescue.target
After=multi-user.target rescue.service rescue.target display-manager.service
AllowIsolate=yes
整个启动过程中的简图如图6-17所示。
图6-17 CentOS 7启动过程简图
6.7 本章重点
1)表6-2中根下的目录结构知识。
2)本章介绍的/etc、/var、/usr等目录下的文件功能和作用。
3)CentOS 6和CentOS 7的启动过程。