首页 » 操作系统 » Linux » 正文

给深度操作系统 deepin 添加 grub2 密码的方法

发布者:站点默认
2018/11/24 浏览数(1,760) 分类:Linux 给深度操作系统 deepin 添加 grub2 密码的方法已关闭评论

生成密码

执行 grub-mkpasswd-pbkdf2

user:~ $ grub-mkpasswd-pbkdf2 
输入口令:
Reenter password: 
PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.1BB9B516B1658C99B71B3A4D4B1268A43A20C3C3AEAC7F558106DBC87118D5C34143005BBCBD5FF06D3158C9823596CD00568EEACB190E2A92D760EC049C9BCE.54A9AB1E031550AA919F67E427E33F2B8F14268FBCFFA4C2BFF51812D5F559142D8B313C63247D22EF3CA97FC4ED87A7B6FEB3764EAA17D4F0B48A5A1EAEB7C8
user:~ $ 

添加到配置文件

打开 /etc/brub.d/40_custom,在文件末尾添加如下两行代码:

set superusers='Mr.User'
password_pbkdf2 Mr.User grub.pbkdf2.sha512.10000.8B1B247CFA4DA8B6C99EF56CFC841966383950B5C5CB9DDC3D56A56FA4DC72C36166E967DA9D72AD677D5E1561ACD8115AB5EA59F846FD3CE2C96D91CC4F8851.34BDE3D35CB00495E83982B2C6C12B0FBF836DCCC93C14613601C5CEFDF8EB9617D7A263D8CA1552F45333D57565CE47C829A1B1CCED6AB5FB2C84448B73D200

操作如下:

user:~ $ sudo vi /etc/grub.d/40_custom 
[sudo] user 的密码:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
set superusers='Mr.User'
password_pbkdf2 Mr.User grub.pbkdf2.sha512.10000.8B1B247CFA4DA8B6C99EF56CFC841966383950B5C5CB9DDC3D56A56FA4DC72C36166E967DA9D72AD677D5E1561ACD8115AB5EA59F846FD3CE2C96D91CC4F8851.34BDE3D35CB00495E83982B2C6C12B0FBF836DCCC93C14613601C5CEFDF8EB9617D7A263D8CA1552F45333D57565CE47C829A1B1CCED6AB5FB2C84448B73D200

更新grub2的配置

执行 update-grub

user:~ $ sudo update-grub
Generating grub configuration file ...
Found theme: /boot/grub/themes/deepin/theme.txt
Found background image: /boot/grub/themes/deepin/background.png
Found linux image: /boot/vmlinuz-4.15.0-29deepin-generic
Found initrd image: /boot/initrd.img-4.15.0-29deepin-generic
Adding boot menu entry for EFI firmware configuration
done
user:~ $ 

完成

重启可见效果,默认读秒已经没有了,进入启动条目后即要求输入帐号和密码。

debian/ubuntu 把 grub 的配置文件拆分了,不能通过直接修改 /etc/grub2.conf,添加 password –md5 的方式添加密码。

-完-

点击返回顶部
  1. 留言
  2. 联系方式