How to change root password in Linux

This is one of the problem faced by many person’s“what if i lost the root password”First thing that comes in mind is “use single user mode” but the answer is NO.

So the BIG QUESTION IS HOW TO proceed further

follow these steps

1) on grub-boot prompt. press “e” to enter edit mode

2) then press downarrow to reach the line that starts with “kernel “ press “e” again

3) at the end of this line type in “init=/bin/sh” or “/bin/bash”

4) then press enter to make that change and press “b” to boot in a few seconds you will be on your “#” prompt

5) only one step left “mount -o remount rw /”

this step is necessary coz in this case root file system is mounted as read only.

6) finally type “passwd” and you get the screen to change the password

and then type in “init 6″ or “reboot”

those who are looking for the technical details, the main work is the init command that we passed as an argument to kernel, it told kernel to specifically run the command specified in parameter instead of working on normal routine.

TRICK = if you have any program you wish to run instead of this then you can do that too using init command only.


About Amol

I'm blogger, avid read, photographer and book lover. Reading a lot of good stuff and sharing it with the world are my passions.
This entry was posted in Linux, Tricks and Tips., Ubuntu and tagged , , . Bookmark the permalink.

3 Responses to How to change root password in Linux

  1. ubuntucat says:

    Shouldn’t this be titled How to change root password in non-Ubuntu Linux distros?

    First of all, Ubuntu doesn’t have a root login enabled by default.

    Secondly, in Ubuntu you can get a root console by booting into recovery mode—you don’t have to do all that Grub e stuff and editing the kernel line.

  2. Amol says:

    Thank you for your correction man, I have made the necessary changes. thank You
    very much.

  3. Sudhanshu says:

    I think booting into a single user mode is easy for beginners to change the root password. i.e. adding a word ‘single’ after you press “e”.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

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

Google+ photo

You are commenting using your Google+ 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