红联Linux门户
Linux帮助

ubuntu中设定grub2密码

发布时间:2016-04-27 10:38:54来源:linux网站作者:Leekwen

直接上操作步骤:

leekwen@leekwen:~# grub-mkpasswd-pbkdf2 
Enter password:       <<<这里输入你的grub密码 
Reenter password:     <<<这里输入你的grub密码 
Your PBKDF2 is grub.pbkdf2.sha512.10000.BC4D0A450E86EE447561FC822C832xxxxxxxxxxxxx45572D3B4E40500CE 
leekwen@leekwen:~# cp /etc/grub.d/00_header /etc/grub.d/00_header.bak 
leekwen@leekwen:~# vi /etc/grub.d/00_header 
leekwen@leekwen:~# tail -n 6 /etc/grub.d/00_header 
### Add those line to set GRUB2 password  
cat <<EOF 
set superusers="leekwen" 
password_pbkdf2 leekwen grub.pbkdf2.sha512.10000.BC4D0A450E86EE447561FC822C832xxxxxxxxxxxxx45572D3B4E40500CE
EOF 
### Add end 
leekwen@leekwen:/etc/grub.d# update-grub <<运行此命令才可以生效 
Generating grub.cfg ... 
Found linux image: /boot/vmlinuz-3.11.0-15-generic 
Found initrd image: /boot/initrd.img-3.11.0-15-generic 
Found memtest86+ image: /memtest86+.bin 
done 


这样重启后,在启动项时,按e后,就会让你输入:

username: 
password: 


只有用户名(比如我刚刚设置的用户名为:leekwen)及密码正确后(刚刚用grub-mkpasswd-pbkdf2生成的密码),才可以进入启动项的编辑菜单,启动项这一步倒是安全了,记住,修改00_header后一定要运行“update-grub”命令,这样才能生效!


本文永久更新地址:http://www.linuxdiyf.com/linux/20134.html