Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the password of the GRUB menu in Centos7.7

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to set the password of the GRUB menu in Centos7.7. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

Most Linux distributions use GRUB 2 as the boot loader. GRUB 2 (GNU Grand Unified Boot loader) is a boot loader package in the GNU project.

GRUB2 provides two types of password protection:

A password is required to modify a menu entry, but not to start a menu entry

A password is required to modify a menu entry and start one, more, or all menu items.

Set the password when you modify a menu entry

Setting a password using grub2-setpassword prevents modification of GRUB menu entries, but does not prevent unauthorized startup. If you also need a password to start the entry, you need to modify the grub configuration file.

On RHEL 7.2and Centos 7 (and later), GRUB 2 uses the grub2-setpassword command to provide password protection.

[root@localhost grub.d] # grub2-setpasswordEnter password:Confirm password:

When you press e or c in the grub menu to edit, you are prompted that you need a user name and password to change it.

This process creates a / boot/grub2/user.cfg configuration file that contains the encrypted password. The user of this password is root, which is defined in the / boot/grub2/grub.cfg file. With this change, you need to specify a root username and password to modify the boot entry during boot.

Set the password when changing menu entries and starting menu entries

Edit the / boot/grub2/grub.cfg configuration file, search for the 10 _ linux keyword, and then modify the entry below to remove the-- unrestricted parameter so that you need to enter a user name and password to boot.

[root@localhost ~] # vim / boot/grub2/grub.cfg

Before modification

Configuration after the-unrestricted parameter is removed

After the modification is completed, save and exit, restart the operating system, and will be prompted to enter the account password when starting the system.

How to change a root user to another user?

The default setting in the Grub.cfg configuration file is the root user, and we can change it to another user.

Edit the / boot/grub2/grub.cfg configuration file, search for the 01 _ users keyword, and change the root to another user, which is changed to the "test" user name.

How do I delete a password?

To delete the password, simply delete the / boot/grub2/user.cfg file.

[root@localhost ~] # rm-rf / boot/grub2/user.cfg

You can use grub's password to protect startup entries and modify entry menus. The grub2-setpassword tool was added in RHEL7.2/Centos7.2 and is now the standard way to set the GRUB 2 password.

This is the end of the password on how to set the GRUB menu in Centos7.7. I hope the above content can be of some help to you and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report