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.