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 :
- Login as Root by typing su - root, and type your password
- Type the command cd /etc/grub.d
- 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
- It will generate your plain text into encrypted text, copy it and open header_00 files by typing nano header_00
- 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 - Now, type update-grub to apply the configuration so it will also applied to grub.cfg
- Restart, and now you may see the grub locked after booting.