Setting Grub 2 Password

I don’t no why I can’t add it before… ;because it’s so easy

  1. First of all, we must define user and password for it.
    • cp /etc/grub.d{,.bac}
      cd /etc/grub.d
      vim 00_header

      cat << EOF

      set superusers=”simon”

      password simon 123456

      password othuser 1234


      • add these lines to end of file

  2. Protecting:
    1. All linux kernels (just linux):
      vim 10_linux

      find this:

      printf “menuentry ‘${title}’ ….

      and change it to:

      printf “menuentry –users simon othuser ‘${title}’ ….

    2. All menu entries:

      sed -i -e ‘/^menuentry /s/ {/ –users simon othuser {/’ 10_linux 20_linux_xen 30_os-prober 40_custom 41_custom

  3. Finish by these commands:


    reboot # have fun 😉