An example of using "chroot" to reset a password of a linux machine

I tried to explain what "chrooting" is to a group of starting Linux gurus. It seemed rather difficult to explain. So, maybe an illustrated article will explain what chroot is.

From chroot's manpage:

chroot - run command or interactive shell with special root directory

And in my own words:

chroot starts a process in a directory which looks like the root directory to that process.

Here is an example of how chroot can be used to reset a root password on an existing system. (Even works when the bootloader (grub) has a password set.)

  1. Insert a linux boot or install CD/DVD and make the computer boot from that cd.
  2. When the CD boots and starts the installer, hit [CTRL]+[ALT]+[F2] to go to a shell.
  3. Now that you have a shell available, you must mount the / (maybe /usr too) directory. Mostly you don't know what directory was the / directory, so you will end up mounting an unmounting a few times. mkdir /mnt/a && mount /dev/sda5 /mnt/a && mount /dev/sda3 /mnt/a/usr
  4. When you have the required mountpoints mounted, execute a chroot, like this: chroot /mnt/a /bin/sh
  5. Now you can execute passwd, which is actually /mnt/a/usr/bin/passwd. The password will be updated in /etc/shadow, which is actually /mnt/a/etc/shadow

Here is a screenshot to illustrate the procedure: (click to enlarge)


Method of using the machine

Method of using the machine of the password. The usage of the password for the protection is here to site and safeguard of the machine. The dynamics are entailed and discussed.

Now, this is really a good

Now, this is really a good source of idea. I'm really looking for this information. - Dennis Wong YOR Health

Good tutorial.Could you

Good tutorial.Could you please use "chroot" example in "how to reinstall grub form a live cd/DVD".Thank you.

I tried to explain what

I tried to explain what "chrooting" is to a group of starting Linux gurus. It seemed rather difficult to explain.

What's a 'starting Linux guru'? You mean a student?

I guess that makes me a 'starting brain surgery guru' because I have access to a knife and gen tell a head from a foot 80% of the time.

Saying 'teacher' in Malay doesn't endow anyone with mystical properties.

hahahahahahaha linux gurus

hahahahahahaha linux gurus you means kids out of school who don't know their ass from their elbow lol...or the idiot who is so crap at his own subject he has decided to become an ad hoc IT guy with no computer science degree he believes he can maser linux by asking them too...nice little article...

About Consultancy Articles Contact

References Red Hat Certified Architect By Robert de Bock Robert de Bock
Curriculum Vitae By Fred Clausen +31 6 14 39 58 72
By Nelson Manning [email protected]