Some times it is possible to change the root password in Red hat El4 without knowing old password when the system boot. but we can prevent this one by using grub password and MD5 encryption
For setting password
# /sbin/grub-md5-crypt
Now enter the password
[root@MB327SCS068 ~]# /sbin/grub-md5-crypt
Password:
Retype password:
$1$plEu7$3eucnZfDe1o1fcmCAtjJ6.
copy the encrypted password
goto /boot/grub/grub.conf file
#vi /boot/grub/grub.conf
add the following line after splashimaget line in that config file
password –md5 encrytpedpassword
[root@MB327SCS068 ~]# vi /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
password –md5 $1$plEu7$3eucnZfDe1o1fcmCAtjJ6.
hiddenmenu
title Red Hat Enterprise Linux WS (2.6.9-5.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-5.ELsmp ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.9-5.ELsmp.img
title Red Hat Enterprise Linux WS-up (2.6.9-5.EL)
root (hd0,0)
kernel /vmlinuz-2.6.9-5.EL ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.9-5.EL.img
Save the file and reboot the system
Thats all