Linux reset password
reset root password
1. when you are in the system, modify /etc/passwd, delete the "x" in root line to clean the password;
2. when you are not in the system, enter the single mode to reset or clean password of root;
When you reset password got error, you may need to close the SElinux: setenforce 0
3. when you are not in the system and not have grub password, use cd to start system.
inpu: linux rescure
after it the hard disk system will be mount below: /mnt/sysimage
change the /etc/passwd and /etc/grub/grub.conf file to clean the password of root;
Linux启动:/boot/grub/grub.conf
去掉菜单的背景色:在"splashimage=(hd0,0)/grub/splash.xpm.gz"行前加"#"手工模拟正常启动:
1. 重启RHEL;
2. 进入选择启动菜单模式,输入"c“,进入command-line
3. 输入:root (hd0,0)回车
4. 输入:cat / 制表键(Tab)查看是否有vmlinuz-......
5. 输入:root (hd0,1)回车
6. 输入:cat / 制表键(Tab)查看是否有/boot;如果没有继续找
5. 输入:root (hd0,2)回车(可以通过输入"root (hd0,制表键"来查看所有的Filesystem列表)
6. 输入:cat / 制表键(Tab)查看是否有/boot;如果没有继续找
7.例如找到在(hd0,7),输入如下内容:
root (hd0,0)回车
kernel / vm制表键 ro root=/dev/hda8回车
initrd / init制表键回车
boot回车
配置单用户模式:
修改文件:/boot/grub/grub.conf
原内容:
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
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修改后:
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
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
title Single mode
root (hd0,0)
kernel /vmlinuz-2.6.18-128.el5 ro root=LABEL=/ single
initrd /initrd-2.6.18-128.el5.img
修改后,重启是需按任意键进入菜单,选择单用户模式
单用户模式,主要用来修改root密码
从单用户模式进入普通模式:init 3
set grub password:
change file:/boot/grub/grub.conf
在"title"行前面加入:password 1111
重启后,就需要输入密码才能登录。
但是这是明文密码,保存不安全。
可以使用加密命令: grub-md5-crypt
将密文复制到grub.conf中
例如:password --md5 <密文>
Comments
Post a Comment