To set a password for GRUB, you need to go through three simple steps. First we generate a password hash, then we need to set it by changing the settings, and at the end we need to update the GRUB configuration. At the same time, I'll tell you how to enable the system to boot without a password, and check if everything works correctly.

Generate Password hash

To generate a password hash, we need the grub-mkpasswd-pbkdf2 utility. It is installed by default in many distributions.

To generate a password hash, just run the command in the terminal:


Then enter the required password for GRUB twice.

Copy the resulting hash and save it somewhere, we still need it. The hash starts with grub.pbkdf2.

If your distribution doesn't have grub-mkpasswd-pbkdf2. This means that the grub-common package is missing from the system. Therefore, it must be installed manually.

If you are using Ubuntu, then install the package with one command:

sudo apt install grub-common

Change GRUB settings

Now you need to assign a super user for GRUB. To do this, we need to edit the following file: /etc/grub.d/00_header.

Open the file with the nano text editor:

sudo nano /etc/grub.d/00_header

Scroll to the bottom of the content. And then on a new line, paste the following information:

cat << EOF
set superusers="userName"
password_pbkdf2 userName

The main thing! Replace userName on the second and third lines with your preferred GRUB superuser name, and replace the password hash with your own.

Update GRUB configuration

Now let's update the GRUB configurations to apply the previously made changes.

To do this, enter a simple command:

sudo update-grub

Restart your computer to check your changes. As soon as the GRUB interface appears, you will be prompted for a username and then a password.


Setting a password for GRUB will be very useful in many situations. This will help make your system more secure, as the regular superuser password is very easy to reset.