Linux基础教程:RHEL红帽企业版Linux系统排错

一、系统故障分析方法和目标

判断问题的性质
重演出错过程
查找进一步信息
从简单的的方法入手
在修改的时候备份配置文件

修复Linux系统不同阶段的故障
将系统引导到不同的运行级别
使用救援模式
二、系统故障排错示例
如下通过4个常见的示例说明系统故障排错的过程,分别是:

系统密码不正确
mbr故障
/etc/fstab文件错误
/etc/inittab文件错误

三、系统密码不正确(忘记了或者说想窃取修改)

忘记登陆系统的root密码,忘记grub引导管理器的密码
这里首先说明一个grup引导管理器密码,通过设置该密码可以防止人编辑启动菜单画面
的选项,若要编辑必须输入密码才可以编辑。设置grub密码的步骤如下:
[root@ ~]# vim /boot/grub/grub.conf
//编辑这个文件
[root@ ~]# cat /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/sda2
#
initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
password=123
//在Linux系统标题上面添加这行
title Red Hat Enterprise Linux Server (2.6.18-128.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-128.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-128.el5.img
保存文件退出…...
然后重启系统,可以发现提示信息说:直接回车可以启动系统,如果要设置菜单选项请
输入“P”。要知道,如果系统没设置grub密码的话是可以直接编辑菜单选项的:

Linux基础教程:RHEL红帽企业版Linux系统排错

输入“P”,然后输入先前设置的密码123 

Linux基础教程:RHEL红帽企业版Linux系统排错

可以发现密码验证过后,提示信息为输入“e”可以编辑菜单选项了

Linux基础教程:RHEL红帽企业版Linux系统排错

输入“e”: 

Linux基础教程:RHEL红帽企业版Linux系统排错

这样就可以设置Linux系统启动级别了,所以说,没有设置grub密码的话,就算不知道root
帐号密码,通过编辑菜单选项就可以通过level 1 启动系统设置密码了。
当然,在设置grub密码的时候一般是使用MD5加密的,通过如下方法设置:
[root@ ~]# grub-md5-crypt
Password:
//输入123
Retype password:
//输入123
$1$q5Ppn/$MZr67rBdz6kIhk0lYDvFh0
//这一行就是123的MD5加密密码
然后编辑/boot/grub/grub.conf文件:
[root@ ~]# vim /boot/grub/grub.conf
[root@ ~]# cat /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/sda2
#
initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
password --md5 $1$q5Ppn/$MZr67rBdz6kIhk0lYDvFh0
//修改成MD5加密的
title Red Hat Enterprise Linux Server (2.6.18-128.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-128.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-128.el5.img
当重启系统后想编辑菜单选项就输入加密密码123

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/23952.html