Linux reset forgotten root password

by on May 13, 2006 · 47 comments· LAST UPDATED September 19, 2007

in , ,

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:

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 47 comments… read them below or add one }

1 shekhar December 14, 2006 at 5:03 am

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

Reply

2 kishor August 11, 2007 at 11:46 am

i want password releated information

Reply

3 sajid November 15, 2007 at 3:49 am

how to reset root password

Reply

4 sapan yadav May 30, 2013 at 11:43 am

please write sudo bash and enter in shell as root and type passwd after that u can change

Reply

5 kekelka December 25, 2007 at 3:12 pm

thxu very much for help

Reply

6 Pin March 13, 2008 at 3:25 am

Very helpful indeed. Manage to reset now.

Reply

7 Sergey August 10, 2008 at 2:33 pm

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

Reply

8 S. Nilesh August 10, 2008 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.

Reply

9 Angel Genchev March 18, 2009 at 7:51 am

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

Reply

10 manoj June 13, 2009 at 5:06 am

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

Reply

11 Phuc August 22, 2009 at 8:02 am

Great help, thanks

Reply

12 George August 29, 2009 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?

Reply

13 georges November 16, 2011 at 10:14 am

you’ll need a live cd for that, and the process will be more complex.
try posting a thread in linuxquestions.org

Reply

14 Maniraj Patri October 16, 2009 at 9:56 am

Will it work for fedora also. Anyway thanks.

Reply

15 Syed Mohammed January 13, 2010 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

Reply

16 georges November 16, 2011 at 10:16 am

did you try what nixcraft suggested, and what was the result?

Reply

17 midhu February 16, 2010 at 4:58 pm

thanku so much

Reply

18 Suryakant February 17, 2010 at 4:19 am

How to reset password if we forget password in linux?

Reply

19 Ramgopal February 25, 2010 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

Reply

20 Prabhu May 13, 2010 at 1:34 pm

Thanks for sharing the useful tips

Rgds
Vipro Computer Services

Reply

21 AJANRAMAN June 10, 2010 at 6:01 am

thank you very much……

Reply

22 win August 25, 2010 at 6:40 am

can’t to reset after booting still view “give root password for maintenance or control d” do you have other solution?

Reply

23 mangesh October 8, 2010 at 8:08 am

now i am working with linux an i forget the linux server root password so i want solution on that so please help me about that

Reply

24 eman October 26, 2010 at 2:58 pm

thanx it worked

Reply

25 Richard December 6, 2010 at 10:17 am

Note that :
1. Linux is case-sensitive.
2. “single” is a keyword.

So, you actually need to add ” s” or ” single”.
(lower case, and you need a space before it)

Reply

26 AVIRAL January 25, 2011 at 8:36 am

sir,
i want to know that if i forget the password of linux. so ho could it possible to work in linux

Reply

27 Anon June 20, 2011 at 2:37 am

You can likely just change root’s password using the normal way if you have sudo permissions: “sudo passwd root”. Setting root’s password initially is likely needed anyway under certain cases, such as when you need to ssh/sftp in as root during emergencies.

Reply

28 brijesh July 3, 2011 at 10:54 am

Thanks Its working

Reply

29 govindaraji July 16, 2011 at 7:17 am

my linux user name & password forget password

Reply

30 Macdonald Rukwata August 12, 2011 at 8:02 am

thank you so much i managed to change the password

Reply

31 Sunag September 12, 2011 at 2:43 pm

i have the latest natty newhal 11.01 ubuntu that just starts off no grub no loading… but i have stuck up with the root password trying to install the JRE platform…

Reply

32 mazhar October 29, 2011 at 7:28 am

Thank Q.
its help me a lot.

Reply

33 Sreekanth November 14, 2011 at 3:51 am

For RHEL-6 do the following in single user mode.

By default SELinux enabled in RHEL-6 and it will not allow you to change the password.
Run the below commands to change the password for root.
#setenforce 0 (check the SELinux changed to Permissive using command “getenforce”)
then go for password reset
#passwd

Reply

34 Eswaramoorthi.D December 8, 2011 at 5:04 am

Thank you

Reply

35 virus December 27, 2011 at 8:19 am

HOW TO CHANGE USERNAME ????????????????????

Reply

36 samish July 24, 2012 at 11:11 am

what if my root folder in fedora is comming with red cross sign i cannot open it

Reply

37 Array August 8, 2012 at 4:36 pm

i need to access our server hosted somewhere but the password is being forgotten….so how do i access the server from remotely….anyone help pls

Reply

38 Usman March 14, 2013 at 7:55 am

Hi,

upon mounting the /proc mount point, i am getting error to specify the file system too. what should i enter there?

Reply

39 Danish Zahur March 29, 2013 at 4:41 am

Working great… Thank you

Reply

40 Timothy June 4, 2013 at 7:18 pm

Am a new linux user.I lost my password for linux mint os how can i rest it and create a new user.Also i keep on reset ing my desktop and time setting every time i power on.The system has no memory of previouse logins

Reply

41 Vdst July 8, 2013 at 7:08 pm

Awesome, thanks for that bit of info!

Reply

42 Calin Vlad December 25, 2013 at 10:41 pm

I encounter the same problem and I solved quite easy I might say
first I wirte
user@pc:~$ sudo bash
[sudo] password for user: (you type your sudo password)
then it automatically switch to
root@pc:/home/user#
here you write
root@pc:/home/user# passwd
and the output is
Enter new UNIX password: (here you write your new password)
then you hit ENTER
and
Retype new UNIX password: (retype your new password)
and if everything goes perfect
you should have this output:
passwd: password updated successfully

Reply

43 Pavlos January 21, 2014 at 4:38 pm

My linux system writes

An error occured during the file system check
dropping you to a shell? The system will reboot when you leave
the shell
Give a root password for maintenance or type control d to continue.

I don not remember the root password
what can i do?

Reply

44 Pavlos January 21, 2014 at 4:40 pm

My boot loader i GRUB

Reply

45 Pavlos January 21, 2014 at 4:49 pm

After the 6th step it starts automatically and it failed

Reply

46 Ravichandran Kingmaker March 7, 2014 at 12:54 am

Which is the kernal line?

Reply

47 Jean-Vitki June 19, 2014 at 3:27 pm

In my Os the kernel line do not appear
I use elementary OS Luna

Reply

Leave a Comment

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

Previous Faq:

Next Faq: