[root@centos7 ~]$ grub2-setpassword #生成一个grub口令
Enter password: #输入密码、如“123.com”
Confirm password: #再次密码、如“123.com”
[root@centos7 ~]$ ls /boot/grub2/ #生成一个 user.cfg
device.map fonts grub.cfg grubenv i386-pc locale user.cfg
[root@centos7 ~]$ reboot #重启
```csharp
按"e"键进入编辑模式
Enter username:
root #输入用户名
Enter password:
123.com #输入密码
完成
清空grub密码
#如果密码忘了、可以把/boot/grub2/user.cfg文件删掉
[root@centos7 ~]#cat /dev/null > /boot/grub2/user.cfg #清空grub密码
或者
[root@centos7 ~]#rm -f /boot/grub2/user.cfg #删除文件