Linux系统的启动原理

Linux系统的启动原理

RHEL的启动原理
BIOS自检-MBR-启动GRUB-加载内核-systemd的init进程

systemd的初始化进程
加载需要的服务,挂载文件系统/etc/fstab
systemd是linux内核启动的第一个进程,取代了init

systemd 的优点:
启动速度快,提供系统服务的快照,服务自动实时更新

pstree 命令可以查看第一个启动的进程,pid是1
---------------
init 与systemd的比较
init0 systemctl poweroff 关机
init1 systemctl isolate rescue.target 单用户模式
init3 systemctl isolate multi-user.target 多用户模式,字符界面
init5 systemctl isolate.graphical.target 图形化界面
init6 systemctl reboot 重启系统

vim /etc/inittab 系统运行级别说明文件
查看当前默认的运行级别
systemctl get-default
设置默认的运行
systemctl set-default

调用字符界面
systemctl isolate multi-user.target
调用字符界面并设置为默认运行级别
systemctl set-default multi-user.target

切换运行级别
systemctl isolate multi-user.target

grub的引导设置
vim /etc/default/grub
使用grub2-mkconfig 让修改生效
查看grub的配置文件
vim /boot/grub2/grub.cfg

覆盖执行
grub2-mkconfig -o /boot/grub2/grub.cfg

systemd 的主要命令是systemctl
systemctl start 服务名称 启动一个服务
systemctl restart 服务名称 重启一个服务
systemctl stop 服务名称 停止一个服务
systemctl status 服务名称 查看一个服务的状态
systemctl enable 服务名称 设置一个服务开机自动启动
systemctl disable 服务名称 设置一个服务开机自动关闭


init5 切换到图形化界面
-----------------------------
查看atd服务的状态、
systemctl status atd

安装Apache软件包
yum -y install httpd
systemctl enable httpd
ststemctl disable httpd
------------------
查看系统中的服务那些是开机自启动的
systemctl list-unit-files --type service
查看系统中服务占用资源的状态
systemd-cgtop

猜你喜欢

转载自www.cnblogs.com/GaoNa/p/11135346.html
今日推荐