Skip to content Skip to sidebar Skip to footer

Add Password To Linux Grub

In my previous post, i am telling you how to open the locked grub so our operating system can be accessed without entering password. But if you still curious what happened and how does things works, or you want to protect it again you can follow the steps below :





  1. Login as Root by typing su - root, and type your password
  2. Type the command cd /etc/grub.d
  3. Now we are in the grub.d folder. Grub configuration is stored in files named header_00. Before we edit that files, lets create an encrypted password for it so none of them could break it easily. To create encrypted password, type

    grub-mkpasswd-pbkdf2<space> your_desired_password
    Now press enter
  4. It will generate your plain text into encrypted text, copy it and open header_00 files by typing nano header_00
  5. Scroll into bottom lines, and type :

    cat << EOF set superusers="username" password_pbkdf2 username 'paste the generated code' EOF
    Save your configuration by pressing ctrl + x and press y
  6. Now, type update-grub to apply the configuration so it will also applied to grub.cfg
  7. Restart, and now you may see the grub locked after booting.