1. 第一步:设置用户名、密码
打开 /etc/grub.d/00_header
在最下面加入
cat << EOF
set superusers="su"
password su 1234
password user1 4321
EOF
su、user1 可以替换成你喜欢的用户名
superuser 是必需的(可以执行和修改任何启动项)
user1 非必需的,可以用于限制不同用户启动不同的系统,可以设置多个
如果你不希望使用明文密码,可以在终端下运行
grub-mkpasswd-pbkdf2
grub.pbkdf2.sha512.10000.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
linux_entry ()<br /> {<br /> os="$1"<br /> version="$2"<br /> recovery="$3"<br /> args="$4"<br /> user="" #新添加
if ${recovery} ; then<br /> title="$(gettext_quoted "%s, with Linux %s (recovery mode)")"<br /> user="--users su" #新添加
else<br /> title="$(gettext_quoted "%s, with Linux %s")"<br /> user="" #新添加
fi<br /> printf "menuentry ${user} '${title}' ${CLASS} {\n" "${os}" "${version}" #${user}为新添加的
cat << EOF
found_other_os=1<br /> cat << EOF<br /> menuentry "${LONGNAME} (on ${DEVICE})" --class windows --class os {<br /> EOF
found_other_os=1<br /> cat << EOF<br /> menuentry "${LONGNAME} (on ${DEVICE})" --users su --class windows --class os {<br /> EOF