Posted by: Rick Cordeiro | April 28, 2007

Recovering your root login passwd on your linux box!

It’s happened to everybody, having a lot of passwords and one of them just slipping our mind, and If your like me, the safest place for passwords is my head, nowhere else do I have passwords. Well here’s an easy way to regain your shell on a Linux box.

1 – Reboot your computer and wait ’till the Grub Boot Menu shows up…
2 – Now go to your Linux boot option and type e
3 – At the end of the boot menu line just type in: init=/bin/bash
4 – Now type b, and you will regain you shell, but wait, that’s not all…

After you regain your shell, your going to have to edit some files, so we’re going to have to mount our filesystem,

5 – Type this in: mount -o rw,remount / and now you have access to all your files..
6 – Now edit your /etc/passwd and/or the /etc/shadow and find the root user line
7 – Remove everything between the first two colons of the root passwd entry; it should end up looking like this “root::…”
8 – Save the file
9 – Type sync and give it an enter a couple of times, to make sure the filesystem syncs your modified data
10 – Reboot and Login as root
11 – Now type in passwd and change your password for the root user.
12 – Violá, you’ve got full access to your system again.

Enjoy,

Rick


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.