Edit GRUB and reset root password, But now we are looking how can set password for grub ??

Posted on Updated on

Login as root
Enter grub mode:
# grub

Use md5crypt to encrypt password:
grub> md5crypt
Password: ******
Encrypted: $1$jxcdN0$hVHViq1aiPf8FziuGJGZp0

Copy down encrypted password:

Exit grub mode:
grub> quit

Modify file /etc/grub.conf:

kate /etc/grub.conf or vi /etc/grub.conf

Insert encrypted password in between “splashimage…” and “title…”:

password –md5 $1$jxcdN0$hVHViq1aiPf8FziuGJGZp0
title BIZ DESK (2.4.20-8elx)

Save edited file

*If you see “#”, means that you have to type the command in the “Terminal” program found on desktop
*Do not include the “#” while executing the command in the “Terminal” program

Now GRUB commands can only be executed at the boot prompt after pressing P and entering the password. However, users can still boot all operating systems from the boot menu.

To prevent one or several operating systems from being booted from the boot menu, add the entry lock to every section in menu.lst that should not be bootable without entering a password.

title CentOS (2.6.18-194.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/1 rhgb quiet
initrd /initrd-2.6.18-194.el5.img

After rebooting the system and selecting the Linux entry from the boot menu, the following error message is displayed:

Error 32: Must be authenticated

Press Enter to enter the menu. Then press P to get a password prompt. After entering the password and pressing Enter, the selected operating system (Linux in this case) should boot.