linux系统引导

【恢复root密码】
一、开机按E进入当前菜单项目
二、找到linux16开头这一行,末尾添加rd.break
三、按ctrl+X键引导系统
四、以读写模式重新挂在root /sysroot文件系统,将目录改名为/sysroot
# mount -o remount,rw /sysroot
# chroot /sysroot
五、修改root密码
passwd
六、给/etc/passwd文件添加标签
# touch /.autorelabel
七、退出chroot,再退出,reboot重新引导系统

【GRUB2命令行】
系统引导
按下C键切换到GRUB命令行接口
grub> insmod lvm #加载LVM模块
grub> ls #列出所有的分区和逻辑卷
grub> cat (lvm/centos-root)/etc/fatab #找出根分区
grub> set root=(lvm/centos-root) #变量设为包含根文件系统设备
linux (hd,msdos1)/vmlinuz-3.10.0-123.e17.x86_64 #输入linux命令,指定内核和根目录分区
root=/dev/mapper/centos-root
initrd (hd,msdos1)/initramfs-3.10.0-123.e17.x86_64 #输入initrd命令,指定初始化RAM磁盘命令和文件位置
grub> boot #输入boot命令

【重新安装GRUB2】
#rpm -qc grub2-tools
#rm -f /etc/default/grub
#rm -f /etc/grub.d/*

yum -y reinstall grub2-tools #安装GRUB2
grub2-mkconfig -o /boot/grub2/grub.cfg #重新生成grub.cfg文件

【GRUB2急救模式】
启动系统选择Troubleshootting选项,并按回车
在shell提示接口中输入chroot /mnt/sysimage命令

【GRUB2与登录】
在systemd中,可将Unix中的理想(一切皆文件)重新表述为(一切都是单元)。单元是systemd的基本构成模块。

【内核与初始化RAM磁盘】
从GRUB2配置菜单中选择了一个内核后,借助于初始RAM磁盘,Linux把引导任务交给内核。初始RAM磁盘实际上是一个文件系统,在/boot目录中的文件名找到(initramfs)。在引导过程中,linux会把该临时文件系统加载到RAM中。然后,linux加载硬件驱动程序,并启动第一个进程systemd。sysemd为initrd,target激活所有系统单元,并将根目录文件系统挂载到sysroot下。最后,systemd在新的根目录中重新启动自己,并激活默认目标的所有单元。

#systemctl list-units --type-service --all 显示所有服务单元的列表
#systemctl list-units --type-target --all 显示所有目标单位

ls -l /usr/systemd/system/runlevel?.target #列出7个运行级别的符号链接

systemctl list-dependcies graphical.target #列出默认的graphical.target单元的所有依赖项

systemctl get-default #获取当前默认的目标
systemctl 7 #修改当前的默认目标

systemctl isolate numti-user-target #将系统移动到多用户目标

systemd-analyze time #显示系统引导所需要的时间
systemd-analuze blame #显示激活每个systemd单位所需要的详细时间

systemctl list-units #列出所有的systemd单元
systemctl list-unit-files #列出单元格的状态

【服务控制命令】
start #启动
stop #停止
restart #停止然后启动
reload #重新加载
status #查看运行状态

systemctl list-unit-files --type=service #启动服务的状态

systemctl list-unit-files | grep postfix.service #查看邮件服务在引导时的状态
systemctl is-enabled postfix-service #启动邮件服务
systemctl enable postfix.service #设置为开机自启邮件服务

【时区配置】
timedatectl

timedatectl list-timezones #显示可用时区的列表
timedatectl set-timezone America/Los_Angeles #切换到不同的时区

systemctl restart chronyd #重启服务
chronyc sources -v #显示时间来源信息

systemctl stop chronyd.service #停止服务
systemctl disable chronyd.service #禁止开机自启

yum -y install ntp #安装ntp RPM包
systemctl start ntpd.service #启动服务
systemctl enable ntpd.service #设置开机自启

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值