Linux reset forgotten root password

by nixcraft · 16 comments

Q. I forgot my root password, how can I get into my system?

A. You can reset forgotten root password under Linux by booting system into single user mode or emergency mode (also known as rescue mode).

My boot loader is GRUB (see LILO boot loader below)

)Following is the procedure to reset root password if you are using GRUB as a boot loader:

  1. Select the kernel
  2. Press the e key to edit the entry
  3. Select second line (the line starting with the word kernel)
  4. Press the e key to edit kernel entry so that you can append single user mode
  5. Append the letter S (or word Single) to the end of the (kernel) line
  6. Press ENTER key
  7. Now press the b key to boot the Linux kernel into single user mode
  8. At prompt type passwd command to reset password:

You need to mount at least / and other partitions:
# mount -t proc proc /proc
# mount -o remount,rw /

Change the root password, enter:
# passwd
Finally reboot system:
# sync
# reboot


My boot loader is LILO

At LILO boot loader type linux single and press [ENTER] key:
Boot: linux single
When you get the # prompt you will need to type passwd root to reset password:
# passwd
Reboot system:
# sync
# reboot

See also:

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 16 comments… read them below or add one }

1 shekhar 12.14.06 at 5:03 am

thanks for useful trick because many time it happens that you forget password

2 kishor 08.11.07 at 11:46 am

i want password releated information

3 sajid 11.15.07 at 3:49 am

how to reset root password

4 kekelka 12.25.07 at 3:12 pm

thxu very much for help

5 Pin 03.13.08 at 3:25 am

Very helpful indeed. Manage to reset now.

6 Sergey 08.10.08 at 2:33 pm

It’s useful not only to change pass, but also to change permissions, edit configs, etc.

7 S. Nilesh 08.10.08 at 4:36 pm

what is the “sync” required for ? btw, I don’t think we have to do mounting if instead of S we append 1 to the end of kernel line… 1 is INIT single user mode.

8 Angel Genchev 03.18.09 at 7:51 am

sync is used to synchronize Disk with OS buffers, e.t. to write any dirty buffers to the disk.

9 manoj 06.13.09 at 5:06 am

How can i change the root password of another computer from this computer on network

10 Phuc 08.22.09 at 8:02 am

Great help, thanks

11 George 08.29.09 at 2:57 pm

I am using Fedora 11 I don’t get the screen with the kernel version come up and I can’t push e to boot to single user mode. What now?

12 Maniraj Patri 10.16.09 at 9:56 am

Will it work for fedora also. Anyway thanks.

13 Syed Mohammed 01.13.10 at 3:32 pm

Dear sir,

We are using server with linux o/s but the login and password has been misplaced so could you kindly help us geting our server started.

Your kind favour will be highly appreciated.

Thanks and kind regards.

Syed Mohammed

14 midhu 02.16.10 at 4:58 pm

thanku so much

15 Suryakant 02.17.10 at 4:19 am

How to reset password if we forget password in linux?

16 Ramgopal 02.25.10 at 5:44 pm

Hi vivek,
Normally in solaris, to reset the password.
boot cdrom -s
mount the root disk
edit the /etc/shadow
null the value
save and sync
umount
reboot.
How to reset the root password in solaris, when the disks are under Veritas.
when it is mirrored under Veritas VM, how do I do? ( consider 2 disks c1t0d0 and c1t1d0). thanks for your time.
-Regards
Ram

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous FAQ:

Next FAQ:

nixCraft FAQ PDF Collection Now Available To All