grub密码设置与修改
默认GRUB启动参数可以的进入单用户模式从而修改root密码,如果想要给GRUB菜单设置密码,可以修改/etc/grub.conf文件 (/boot/grub/grub.conf)
设置grub密码
密码生成
grub-md5-crypt 生成md5密码
grub-crypt 生成sha256密码
写入配置文件
vim /etc/grub.conf
1 # grub.conf generated by anaconda 2 # 3 # Note that you do not have to rerun grub after making changes to this file 4 # NOTICE: You have a /boot partition. This means that 5 # all kernel and initrd paths are relative to /boot/, eg. 6 # root (hd0,0) 7 # kernel /vmlinuz-version ro root=/dev/sda2 8 # initrd /initrd-[generic-]version.img 9 #boot=/dev/sda 10 default=1 11 timeout=5 12 splashimage=(hd0,0)/grub/splash.xpm.gz 13 hiddenmenu 14 password=123456 #明文密码 15 #password --md5 $1$XEWYA/$5HUOCImxTf4UwpYQGMlue/ #密文密码 md5密码123456 16 #password --sha-256 $5$hwX.zwZ7EMcJW0Tu$GaZZGQzvAAPfSUpK5mW.Jq3v4hZ/1IludjcWmjwPMT3 #密文密码sha密码123456 17 title CentOS (2.6.32-642.13.1.el6.i686.debug) 18 root (hd0,0) 19 kernel /vmlinuz-2.6.32-642.13.1.el6.i686.debug ro root=UUID=a298ed8b-f1b6-409b-a17c-59e72d 401964 rd_NO_LUKS KEYBOARDTYPE=pc
KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LV M rd_NO_DM 20 initrd /initramfs-2.6.32-642.13.1.el6.i686.debug.img 21 title CentOS (2.6.32-642.13.1.el6.i686) 22 root (hd0,0) 23 kernel /vmlinuz-2.6.32-642.13.1.el6.i686 ro root=UUID=a298ed8b-f1b6-409b-a17c-59e72d401964 rd_NO_LUKS
KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_N O_DM 24 initrd /initramfs-2.6.32-642.13.1.el6.i686.img 25 title CentOS 6 (2.6.32-642.el6.i686) 26 root (hd0,0)
重启系统进入grub,输入p,会提示输入密码
grub密码清除
1.在bios中进行光驱引导.
2.开机选择Bescure installed system.
3.选择语言.
4.根据自己的需要配置网卡.
5.系统会自动查找磁盘中的Linux分区并尝试将其挂载到/mnt/sysimage目录,选continue..
6.当出现这个提示的时候应该记住,他提示的命令:chroot /mnt/sysimage.
7.选择shell.
8.紧接着下面会出现shell,并在端口中输入chroot /mnt/sysimage.
9.执行vi /etc/grup.conf,删除配置文件中的密码.
10.保存退出,关机重启,不要忘记修改bios.