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.

Related Articles

Difference Between su and sudo and How to Configure sudo in Linux VPS.

As we know Linux provides much better security. You can set user management policy and user...

Virtual Machine with CentOS 5 32-Bit OS Does not Address Physical Memory More Than 3 GB

Recently we came across very strange issue wherein Linux virtual machine with Centos 5.X 32 Bit...

How to Compress and Extract Files Using the tar Command on Linux?

It is a very easy step to create archive files with .tar.gz or .tgz files. It is also called...

Fix :: SSH Error: Starting sshd: Missing privilege separation directory: /var/empty/sshd

Problem Statement Could not connect to Linux machine through SSH. Error Message While starting...

How to Prevent File/Directory Modification, Deletion and Renaming in Linux?

If you are looking to prevent any file from being modified, delete or renaming, you will need to...

  • 0 Users Found This Useful

Was this answer helpful?