Follow these steps to reset a forgotten root password in Linux:
If you should happen to forget your Linux root password, you are
going to have to change it. Here’s how:
- Start your computer
- Follow the “Booting into single user mode”below
for your type of boot loader.
- Then type passwd and enter the password that
you want the root user to have. It should then say, “All
tokens updated successfully.”
- Restart the machine and you will be able to loot in as root
with the new password.
Booting into single user mode
If using LILO, access the boot: prompt by pressing the [Ctrl]
and [X] keys together. Then type linux single
If you are using GRUB, follow these steps:
Reseting the root password using the GRUB editor - Boot the system and press any key to stop the boot process
when the GRUB menu displayed.
- At the kernel line, press a to append the command line.
- At the end of the line add single or –s and press enter
- Once the system has booted up into single user mode change
the root password.
- At the pound sign type: passwd root
- Once you have change the root password and are back at the
pound sign type: exit this will finish the normal boot up with
your new
root password.
Reseting passwords by using a boot disk and editing the password
file
Follow these steps to reset the password using any RedHat
install CD:
Reboot the system and configure it to boot from the CD.
At the Boot Prompt enter: linux rescue
Once the system finishes booting, press <Ctrl> + <Alt> + <F1> (The
Control, Alt and F1 key together) to switch to a virtual terminal.
Type mkdir mountplace to create a directory called 'mountplace'.
This is where we will mount the filesystem.
Type mount /dev/hda0 mountplace.
Change to the "/etc" directory on your root partition
by typing cd mountplace/etc.
Use vi editor and open the 'shadow' file for editing.
Scroll down to the line containing the root user's information,
which looks something like:
root:dsfDSDF!s:12581:0:99999:7:::
Delete everything between the first and second colons, so that
the line looks like:
root::12581:0:99999:7:::
Save the file and exit your editor.
Type cd to return to your home directory.
Type umount mountplace to unmount the partition.
Type reboot to reboot your system, and remove the RedHat install
CD from the drive.
Now you can log into your system as root with no password. Make
sure you change the password immediately.
|