GRUB called as Grand Unified Bootloader is a default Boot loader on Unix OS. In a Linux system, anyone can log in to single-user mode and change the system settings. This is one of the security threat and to avoid this we can we require Grub to set password protected.
- Login with the root user.
- Hit the below command. It will ask for password and generate an md5 hash password. Copy it at a safe location.
password --md5 $1$b7MLm0$UHtg4Ro6v/JrkWk8yBLMK0
- Open the file /boot/grub/menu.lst or /boot/grub/grub.conf and add the saved md5 password which we have generated earlier.
# vi /boot/grub/grub.conf
IMP Note: Please take the backup of your grub file without fail so we can restore it if there is an issue.
- Now, add the generated md5 password into grub.conf file as password –md5
- Save the file by pressing ESC and type:wq to save and exit.
- Reboot your server.
- Now, whenever you will need to edit the grub menu, you will need to provide the password as per the below image.