麒麟桌面操作系统上使用liveCD取消GRUB密码

鹏大搞运维 2024-06-30 15:31:05

原文链接:

Hello,大家好啊!今天给大家带来一篇在麒麟桌面操作系统上使用liveCD取消GRUB密码的文章。GRUB(GRand Unified Bootloader)是一个非常强大的引导加载程序,可以用来引导多个操作系统。有时候为了系统安全,我们会给GRUB加上密码。但在某些情况下,我们可能需要取消这个密码。本文将详细介绍如何在麒麟桌面操作系统上通过命令行取消GRUB密码。欢迎大家分享转发,点个关注和在看吧!

什么是GRUB密码?

GRUB密码是用来保护GRUB引导菜单的密码,防止未经授权的用户修改引导配置或启动特定的操作系统。设置GRUB密码可以增加系统的安全性,但在某些情况下可能需要取消它。

1.查看系统信息

pdsyw@pdsyw-pc:~/桌面$ cat /etc/os-release NAME="Kylin"VERSION="银河麒麟桌面操作系统V10 (SP1)"VERSION_US="Kylin Linux Desktop V10 (SP1)"ID=kylinID_LIKE=debianPRETTY_NAME="Kylin V10 SP1"VERSION_ID="v10"HOME_URL="http://www.kylinos.cn/"SUPPORT_URL="http://www.kylinos.cn/support/technology.html"BUG_REPORT_URL="http://www.kylinos.cn/"PRIVACY_POLICY_URL="http://www.kylinos.cn"VERSION_CODENAME=kylinUBUNTU_CODENAME=kylinPROJECT_CODENAME=V10SP1KYLIN_RELEASE_ID="2303"pdsyw@pdsyw-pc:~/桌面$ uname -a

2.打开grub验证

3.设置密码

4.授权

5.重启系统

6.点击高级选项

7.进入恢复模式

8.测试需要输入用户名密码

9.进入恢复模式

10.重启系统livecd进入

11.试用

12.查看磁盘信息

kylin@kylin:~/桌面$ sudo -iroot@kylin:~# blkid /dev/sda1: LABEL="SYSBOOT" UUID="59934b04-8cd8-46d5-ad72-2a216817b9c5" TYPE="ext4" PARTUUID="9a04c9fb-01"/dev/sda5: LABEL="SYSROOT" UUID="c901b585-bcfa-483a-84b2-2f3afe8a16b1" TYPE="ext4" PARTUUID="9a04c9fb-05"/dev/sda6: LABEL="DATA" UUID="16cbb1e6-02d5-471d-b8fc-856efa4ec6a5" TYPE="ext4" PARTUUID="9a04c9fb-06"/dev/sr0: BLOCK_SIZE="2048" UUID="2023-04-27-16-25-40-00" LABEL="Kylin-Desktop-V10-SP1" TYPE="iso9660"/dev/loop0: TYPE="squashfs"/dev/sda7: LABEL="SWAP" UUID="fe12e3c4-07b0-4408-a6b1-45c653b5f25c" TYPE="swap" PARTUUID="9a04c9fb-07"root@kylin:~#

13.挂载系统磁盘

root@kylin:~# mount /dev/sda5 /mnt/root@kylin:~# mount /dev/sda1 /mnt/boot/root@kylin:~# mount --bind /dev/ /mnt/dev/root@kylin:~# mount --bind /dev/pts /mnt/dev/ptsroot@kylin:~# mount --bind /sys /mnt/sysroot@kylin:~# mount --bind /run /mnt/runroot@kylin:~# mount --bind /proc /mnt/procroot@kylin:~# chroot /mnt/root@kylin:/#

14.注释grub中的密码内容

root@kylin:/# vim /etc/grub.d/00_header root@kylin:/# root@kylin:/# grep superuser /etc/grub.d/00_header #set superusers=root#export superusers#set superusers=root#export superusersroot@kylin:/# grep password /etc/grub.d/00_header ###grub-password begin#password_pbkdf2 root grub.pbkdf2.sha512.10000.0A49BAB93722E69D5B844355D5817D4B536BC24D263EA7C2EB4F139103AE354B13D1ECF3F6BD757CB22B17C4B21C6E85B891BB242521FF58D947B856A7580883.1E596FBD5B51E0CEF84A456AB989A4BCA9CF0C94C1A7D7060E4D6A2A12A6017730DB480DF9E0306EF21E5603351F60AFAE4D58E29B1489D594AF63C7D8F0088E###grub-password end###grub-password begin#password_pbkdf2 root grub.pbkdf2.sha512.10000.0A49BAB93722E69D5B844355D5817D4B536BC24D263EA7C2EB4F139103AE354B13D1ECF3F6BD757CB22B17C4B21C6E85B891BB242521FF58D947B856A7580883.1E596FBD5B51E0CEF84A456AB989A4BCA9CF0C94C1A7D7060E4D6A2A12A6017730DB480DF9E0306EF21E5603351F60AFAE4D58E29B1489D594AF63C7D8F0088E###grub-password endroot@kylin:/#

15.更新grub配置

root@kylin:/# grub-install /dev/sda正在为 i386-pc 平台进行安装。安装完成。没有报告错误。root@kylin:/# update-grubCurrent environment is chrootwaiting update-grubSourcing file `/etc/default/grub'Sourcing file `/etc/default/grub.d/init-select.cfg'正在生成 grub 配置文件 ...找到主题:/usr/share/grub/themes/UKUI/theme.txt找到 Linux 镜像:/boot/vmlinuz-5.4.18-85-generic找到 initrd 镜像:/boot/initrd.img-5.4.18-85-generic找到 initrd 镜像:/boot/initrd.img-5.4.18-85-generic完成root@kylin:/#

16.退出chroot重启系统

root@kylin:/# exitexitroot@kylin:~# reboot

17.点击enter

18.高级选项

19.恢复模式

20.无密码进入

21.进入恢复模式

通过本文的介绍,您应该已经了解了如何在麒麟桌面操作系统上通过命令行取消GRUB密码。这可以帮助您在需要时取消对GRUB引导菜单的密码保护。如果您觉得这篇文章有用,请分享和转发。同时,别忘了点个关注和在看,以便未来获取更多实用的技术信息和解决方案。感谢大家的阅读,我们下次再见!

0 阅读:1

鹏大搞运维

简介:感谢大家的关注