Linux reset forgotten root password

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:

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!

{ 9 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

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>

Tagged as: , , , , , , , , , ,

Previous post: Linux copy data from a floppy to hard disk

Next post: Linux Virtual Private Network setup