Home > Linux / Unix, Security, Tutorial > How to reset Ubuntu root password

How to reset Ubuntu root password

If your memory or mistyping leaves you without the right password to get into an account on a Linux computer, there’s no need to reformat. You’ll just need to reboot into single user mode to reset it. Here’s how to do it on a typical Ubuntu machine with the GRUB bootloader:

  1. Reboot the machine.
  2. Press the ESC key while GRUB is loading to enter the menu.
  3. If there is a ‘recovery mode’ option, select it and press ‘b’ to boot into single user mode.
  4. Otherwise, the default boot configuration should be selected. Press ‘e’ to edit it.
  5. Highlight the line that begins with ‘kernel’. Press ‘e’ again to edit this line.
  6. At the end of the line, add an additional parameter: ‘single’. Hit return to make the change and press ‘b’ to boot.
Change the admin password

The system should load into single user mode and you’ll be left at the command line automatically logged in as root. Type ‘passwd’ to change the root password or ‘passwd someuser’ to change the password for your “someuser” admin account.

Reboot

Once your done, give the three finger salute, or enter ‘reboot’ to restart into your machine’s normal configuration.

That’s all there is to it. Now just make sure to write your password down on a post-it and shove it somewhere safe like under your keyboard. :)

[ Source: Hackzine.com ]

About these ads
  1. Lisa
    September 11, 2008 at 8:37 pm | #1

    I have tried this and it still does not work. Is there another option i can try? If not then how can i re-install Ubuntu via an NON admin user account ( I cannot remember my password in order to get into my main user account.) I have reset the password before but i have not used this system in such a long time i cannot remember what i changed it to…

  2. September 12, 2008 at 4:47 pm | #2

    Hi Lisa,

    Why is the option above not work? Could explain the steps that you use.

  3. Alan
    January 6, 2009 at 2:54 am | #3

    At least with 8.10, when you select single user mode (either by adding single to your usual kernel line or using the recovery version in grub) you are forced into a Recovery Menu.

    If you choose “root – Drop to root shell prompt” you are still prompted for the root password and are unable to reset it.

  4. Anthony LaFace
    April 9, 2009 at 5:14 am | #4

    you are brutal, your advice sucks

  5. mjavier2k
    May 13, 2009 at 9:08 am | #5

    goto recovery mode then add “rw init=/bin/bash ” press enter, then press b to boot your system.

    hope this helps.

  6. May 26, 2009 at 6:41 pm | #6

    i can’t understand that….
    and i was try this command to reset my password..
    but i m not successful.
    Plz tell me how to reset my root password on ubuntu.plz plz plz plz

  7. July 18, 2009 at 11:00 pm | #7

    Recovery mode, then drop to command line on Ubuntu worked great for me. thanks for the help!

  8. Jaunty
    October 29, 2009 at 1:28 am | #8

    Excellent! This lead me to right place. I’m using Jaunty.

    My route:
    1. Reboot the machine.
    2. Press the ESC key while GRUB is loading to enter the menu.
    3. Select ‘recovery mode’ option.
    4. Select ‘drop to root shell prompt’.
    5. ‘# nano /etc/passwd’ gives you a list of users
    6. change any users password with ‘# passwd [username]’

  9. January 14, 2010 at 1:59 am | #9

    Adding rw init=/bin/bash to the end of the kernel line in the recovery mode boot option worked for me. (“e” on recovery mode option, then “e” on kernel line to get there)
    Thanks mjavier2k .

  10. joserot
    May 16, 2010 at 2:49 am | #10

    Mjavier2k… thanks. you have the truth…

  11. vimal
    September 15, 2010 at 2:36 am | #11

    for me grub not loading , It shows black screen before loading OS and when i press ESC button ,there is no effect on it, and it directly load OS .
    I need to recover my root password

  12. October 1, 2010 at 10:33 pm | #12

    I use the init=/bin/bash and I get a root shell in fact but no useful commands work! neither passwd nor useradd nor anything. :/

  13. October 19, 2010 at 5:40 am | #13

    thankyou for the gud article. keep writing such
    articles. recently i had to reset my windows xp administrator password and a post on reset windows password at http://blog2wptest.blogspot.com really helped me

  14. January 14, 2011 at 1:53 am | #14

    It’s all about the blacks people….don’t you know that by now?

  15. CDGB
    March 18, 2011 at 7:41 pm | #15

    Wow, the ‘rw init=/bin/bash’ worked for me too. Been a Linux admin for nearly 10 years and never knew that one :)

  16. sef5
    June 7, 2011 at 11:53 am | #16

    it work for us too..the whole class is doing this password changing

    rw init=/bin/bash’

  17. kaisha
    June 25, 2011 at 3:40 am | #17

    Worked for me. (Ubuntu running in virtualbox on mac 0s) THANK YOU!!!

  18. jaics
    July 22, 2011 at 1:43 am | #18

    when i used rw init=/bin/bash …there was no user mounted….when i used mount /usr
    it said ther in nothing in /etc/fstab or /etc/mtab…smbody help…iam using ubuntu 11

  19. July 22, 2011 at 8:29 am | #19

    boot with rw init=/bin/bash then reset the root password with “passwd”. Reboot again (w/o the rw… ) then login as root …

  20. Mallappa KTRC
    August 4, 2011 at 10:16 pm | #20

    why Ubuntu 11.04 password didn’t recover

  21. befr33
    August 14, 2011 at 8:22 am | #21

    I used a password with an @ sign in it, and it didn’t seem to like it
    Now I’m trying to reset, I choose Recovery, Drop to shell prompt, and I’m asked for root pw
    Is there a way to get to sinlge user mode? I can’t enter commands by the login prompt
    Grateful for any assistance. This is for Ubuntu 11.04 running in VMware Fusion on a Mac, version

  22. August 18, 2011 at 2:27 pm | #22

    blablabla ro single rw init=/bin/bash –> ctrl + X

  23. Guilherme
    October 15, 2011 at 7:09 am | #24

    thanks tubelawak!

  24. Hof
    January 9, 2012 at 3:32 pm | #25

    After trying this about 5 times I gave up. The procedure does not work, you are STILL prompted for the password. I.e, this advice is a load of crap

  25. OldManRiver
    January 18, 2012 at 7:50 am | #26

    All,

    I had the problem with the error of “No sudoers users exist”, so found and followed the howto at:

    http://www.psychocats.net/ubuntu/resetpassword

    with the exception of using “Shift” for accessing grub2, and then edited both my:

    /etc/sudoers
    /etc/passwd

    I found I had correctly created the users in the sudoers file, but the permissions were wrong in the passwd file.

    You should see something like:

    myuser:x:1000:1000:myuser,,,,:/home/myuser:/bin/bash

    For the user you need root access for change the line to:

    myuser:x:0:0:myuser,,,,:/home/myuser:/bin/bash

    and save. Notice the root user has the “0:0″ value and all users set to “0:0″ will obtain root access.

    I did this, exited the root shell with “exit” then selected “Continue in normal mode”, logged in with the root modified user and prompt came up:

    root@boxname:/

    so knew I had root access and could continue administration of my server box.

    Hope this helps and was clear enough!

    Cheers!

    OMR

  26. Naaveen
    July 26, 2012 at 9:41 pm | #27

    Easiest way to recovery the root password is
    open the terminal with normal login and type sudo passwd root
    it will ask the password for current login after successful login it prompt for new root password

    • August 9, 2013 at 3:57 am | #28

      Thank you so much! I’d tried several of the other suggestions above to no avail. This simple solution is the one that saved me.

      • August 9, 2013 at 5:19 am | #29

        Naaveen :
        Easiest way to recovery the root password is
        open the terminal with normal login and type “sudo passwd root”
        it will ask the password for current login after successful login it prompt for new root password

        No that is the insanity way as, if the person lost the password or it is corrupted, anything they respond with “it will ask the password for current login” will fail, because they would not be looking to reset the password if they already knew it.

        Cheers!

        TBNK

  27. iwank
    September 6, 2012 at 12:23 am | #30

    vimal :
    for me grub not loading , It shows black screen before loading OS and when i press ESC button ,there is no effect on it, and it directly load OS .
    I need to recover my root password

    Me too, please help ..

  28. December 11, 2012 at 11:04 am | #31

    I do not know whether it’s just me or if perhaps everyone else experiencing issues with your blog. It appears as if some of the written text on your posts are running off the screen. Can somebody else please comment and let me know if this is happening to them too? This might be a issue with my internet browser because I’ve had this happen before.

    Appreciate it

  29. May 3, 2013 at 3:02 am | #32

    My spouse and I absolutely love your blog and find a lot of your post’s to be exactly what I’m looking for.
    Would you offer guest writers to write content in your case?
    I wouldn’t mind creating a post or elaborating on many of the subjects you write with regards to here. Again, awesome website!

  30. August 4, 2013 at 10:20 pm | #33

    However, it is undoubtedly very important to create a banner
    that actually signifies your motive and campaign in proper
    manner. Our vinyl banners are printed at up to 1440dpi, with
    UV protected inks, finished with moulded, strengthened plastic eyelets, or with pole
    pockets, which ever meets your needs. You should try to promote your stand five or six months
    in advance.

  31. August 10, 2013 at 8:09 pm | #34

    I blog quite often and I truly thank you for your content.
    Your article has truly peaked my interest. I am going to book mark
    your site and keep checking for new details about once a week.
    I opted in for your Feed too.

  32. October 18, 2013 at 4:27 am | #35

    ต่ำกว่า 18 ห้ามคัดลอกลิงค์ น่ะจ้า

    >>>>>>>>>>>>>>>>>>>> เวป มวยไทย 2000ปี ( น้องโจ
    มวยไทย 2000 ปี ) โคตร มวยหู

    085-7377349 รายสัปดาห์ 500 รายเดือน 1500 สายส่วนตัว 2000

    ไม่ประชุมสาย สดๆ ในเวที มีของให้เล่น เน้นมวยรอง

    เครื่องต่อ เครื่อง ไม่ผ่านกล่อง เสียงเร็วกว่าภาพที่เห็น

    .เเจ้งให้ทราบ เนื่องด้วยขณะนี้ พวกมวยหู ก็อป ไร้คุณภาพ ระบาดหนัก จะสมัคร หูครั้งใด เรียกใช้ น้องโจมวยหู นะครับ สนใจ
    โทร 085-7377349 โจมวยหู
    …จะสมัครหู ขอบเวที โทรมาที่ 085-7377349 น้องโจมวยหู ระดับโลก ……085-7377349 ที่เด็ด มวยตู้…………รับรองไม่ผิดหวัง ติดต่อ 085-7377349 น้องโจ มวยหู

  33. November 18, 2013 at 12:38 am | #36

    If some one wants to be updated with latest technologies
    after that he must be visit this site and be up to date every
    day.

  34. January 11, 2014 at 2:58 am | #37

    Even the quotes for facebook give a tough competition for their counterparts.
    GPS Tracking device can fit in any device and is available in
    all sizes with which tracking and locating of your belongings has become
    easier and efficient. One of the latest trick to avoid the firewalls in schools
    and offices now a days is very popular known as Translator.

  35. April 10, 2014 at 5:12 am | #38

    I loved as much as you’ll receive carried out right here. The sketch is attractive, your authored subject matter stylish.
    nonetheless, you command get got an impatience over that you wish be delivering the following.

    unwell unquestionably come more formerly again as exactly
    the same nearly very often inside case you shield this hike.

  1. November 9, 2011 at 12:40 am | #1

Leave a Reply

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

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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: