How to Protect GRUB with Password in Linux ?

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.

  1. Login with the root user.

  2. Hit the below command. It will ask for password and generate an md5 hash password. Copy it at a safe location.

    # grub-md5-crypt
    password --md5 $1$b7MLm0$UHtg4Ro6v/JrkWk8yBLMK0


  3. 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.

  1. Now, add the generated md5 password into grub.conf file as password –md5



  2. Save the file by pressing ESC and type:wq to save and exit.

  3. Reboot your server.

  4. Now, whenever you will need to edit the grub menu, you will need to provide the password as per the below image.

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to install Git on Centos7?

Git is a famous version-control system. Git is used to tracking the changes made on your code as...

How to Disable SELinux on CentOS?

SELinux called Security-Enhanced Linux is a security module of Linux kernel which provides...

How to transfer cPanel accounts from Shared Hosting to VPS/Dedicated Server manually?

cPanel facilitates you to restore full cPanel account along with websites, email accounts, MySQL...

How to Setup MySQL Master-Slave Replication on RHEL 7?

In MySQL Replication process, one server data is automatically copied to another backup server in...

How to Manage Linux Cloud VPS From Client Area?

This article will assist you to manage your Linux Cloud VPS from client area (though you will...