Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to reset my password. I have followed these steps:

How do I reset a lost Administrative (root) password?

However, then I go to "root" or "netroot" recovery options, it tells me:

Give root password for maintenance (or type Control-D to continue)

Clearly, I do not know the root password. If I type Control-D, I return to the list of options. From this page I read:

Under chapter 'The Other Way':

4. Highlight the line that begins kernel and press 'e' to edit`

But in the grub configuration file I have no line that starts with kernel. Only:

  • setparams 'Ubuntu...'
  • recordfail
  • set gxfpayload...
  • insmod part_msdos
  • insmod ext2
  • set root=...
  • search --no-floppy...
  • linux /boot/vmlinuz-2.6.38...
  • initrd /boot/initrd.img-2.6....

Those are all lines in my grub. Which line should I edit? Or is there another way to reset my password?

share|improve this question
Please see this answer:… – cprofitt Apr 13 '12 at 14:50
That does not work, it tells me to type the password... – please delete me Apr 13 '12 at 14:51
It means this line linux /boot/vmlinuz-2.6.38... Did you set a root password? – 23 93 26 35 19 57 3 89 Apr 13 '12 at 15:04
@forestpiskie I tried that line but it then freezes... just nothing happens. Not sure about root password being set; this is not my own computer (assisting a friend). – please delete me Apr 13 '12 at 15:16
Are you trying to hack yourself into a computer? Because if you don't know the root password and the first user password, it is a bit smelly... – gajdipajti Apr 13 '12 at 20:23
up vote 18 down vote accepted

Since you cannot access recovery mode, you'll have to change the password by accessing your installed Ubuntu system from a live CD/DVD or live USB system.

This is easiest if you can already use the Ubuntu system (even without administrative access). But it's not too much harder if you can't.

  • In my experience, most Ubuntu users who end up locked out of their own systems have automatic login enabled, which is how they forget their passwords (because they don't have to type them in to log in). This may or may not be the case in your situation, but I have presented how to do this if you can use the installed Ubuntu system first because I think that will help the most people who read this post.

If You Can Use the Installed Ubuntu System, Even As a Non-Administrative User

  1. If you don't already have one, burn an Ubuntu live CD/DVD (on Ubuntu, Windows, or Mac OS X) or write an Ubuntu live USB flash drive (on Ubuntu, Windows, or Mac OS X).

  2. If you know the device name of the partition that contains your Ubuntu system's root filesystem, feel free to skip to step 5.

  3. In your Ubuntu system (not the live CD/DVD/USB system), run this command in the Terminal:

    mount | grep ' on / '

    You should include the spaces before on and after /.

  4. That command produces something like /dev/sda1 on / type ext4 (rw,errors=remount-ro,commit=0) as the output. The text before on (not including the space) is the device name of the partition that contains your Ubuntu system's root filesystem. Remember it (or write it down).

  5. Boot the computer from the live CD/DVD/USB and select Try Ubuntu without installing (not Install Ubuntu).

  6. Open up a Terminal window (Ctrl+Alt+T).

  7. Run this command:

    sudo mount /dev/sda1 /mnt

    Replace /dev/sda1 with the device name of the partition containing your Ubuntu system's root filesystem, if different.

  8. Run this command:

    sudo chroot /mnt
  9. Perform one of these tasks, to obtain/restore access to the install Ubuntu system.

    • If you want to reset a user's password:

      passwd username

      Replace username with your username. (This is the username on the system installed on the hard drive, and not "ubuntu" which is the username of the default user on the Ubuntu Desktop Install CD.)

      • If you don't know your username, you can get a list of users on the system by running:

        ls /home

        This works because /home contains all the users' home directories, and the name of a user's home directory is the same as the name of the user.

      Enter the password you want for that user.

    • Alternatively, if you want to set/reset the root password:

      Since you're in a root shell, you can use the passwd command with no arguments to reset root's password:


      But please see this page, which explains why having the root account enabled is not recommended in Ubuntu.

    • Alternatively, if you want to make a user an administrator (so they can perform administrative actions including running commands as root with sudo):

      In Ubuntu 12.04 and higher (you can run lsb_release -r to see what version of Ubuntu you have, just make sure you run it in the chroot or it will tell you what version the live CD has), run:

      usermod -a -G sudo username

      In Ubuntu 11.10 and lower, administrative abilities were conferred by membership in the admin group rather than the sudo group. So then you would instead run:

      usermod -a -G admin username

      In both cases, replace username with the name of the user account you want to give admin powers.

  10. Run these three commands:

    sudo umount /mnt

    The last of those commands quits the Terminal window.

  11. Reboot the system by clicking the power icon on the upper-right corner of the screen and clicking Shut Down. (Then click Restart in the dialog box that comes up.) Make sure to remove the CD/DVD or USB flash drive before the system boots up again, so that you can get into your Ubuntu system on the hard disk.

    • If you're running an old enough Ubuntu live CD that there is a Restart option in the power menu, you should click that rather than Shut Down.

If You Cannot Use The Installed Ubuntu System At All

If you can't log on to obtain the device name of the partition that contains your Ubuntu system's root filesystem, you can figure it out after booting the live CD. There are several ways to do this. I present the one here that I consider easiest (and least likely to lead to mistakes).

  1. If you don't already have one, burn an Ubuntu live CD/DVD (on Ubuntu, Windows, or Mac OS X) or write an Ubuntu live USB flash drive (on Ubuntu, Windows, or Mac OS X).

  2. Boot the computer from the live CD/DVD/USB and select Try Ubuntu without installing (not Install Ubuntu).

  3. Open GParted. To do this, click the home button (i.e., the button at the upper-left corner of the screen with the Ubuntu logo on it) or press Super. Then type in gparted. GParted will come up, and you can click it.

    • On older versions of Ubuntu that aren't running the Unity or Unity 2D interface, open GParted from the top menu by clicking System > Administration > GParted Partition Editor.
  4. Now you can see all your partitions graphically. If you have more than one drive, you may need to select the one that contains your Ubuntu system, in the drop-down menu at the upper-right corner of GParted.

  5. The partition that contains your Ubuntu system's root filesystem is most likely a large partition of type ext4 (or for very old Ubuntu systems, ext3). Usually there is only one ext4 (or ext3) partition, or just one big one. Otherwise, one might be the / partition (containing the root filesystem, this is what you want) and the other might be the /home partition. So if there are two large ext4 or ext3 partitions, you can assume the first one (shown farthest to the left) is probably the one that contains your system's root filesystem. This could possibly be wrong, but nothing will be damaged by these instructions if you are. (In some other situations, it would not necessarily be safe to make this assumption.)

  6. Remember, or write down, the device name of the partition that (probably) contains the root filesystem. GParted shows this to you. It usually takes the form /dev/sdXN where X is a lower-case letter and n is a number.

  7. Quit GParted.

  8. Follow the instructions above ("If You Can Log On as a Non-Administrative User"), starting with Step 6.

These instructions are adapted from post #9 (which I wrote) in this Launchpad Answers question.

share|improve this answer
Thanks. Accepting this because it addresses the issue that I encountered (which is what to do if the regular "password reset" options do not work). Not entirely sure if this will work because I already formatted the system, but I believe this could very well work. – please delete me Jun 8 '12 at 23:17
+1 awesome explanation! – Anand Rockzz May 27 at 20:06

If you need to change your root password but do not know the old one. You will need to drop to a root shell. When you boot into your computer, as soon as the bios screen disapperes (the srceen with your computers logo on it), start tapping the Shift key untill the grub menu comes up, and if this option does not work, then tap the esc key. (if it is already configured to come up then this step is not nessessery)

When you see the menu choose the option of the latest kernel (or the one you normally use) and choose the option right below called "recovery mode" It should look like this:

enter image description here

This will take you to a menu looking something like this: enter image description here

Next choose the Root option

Wait and let everything load untill you get to a shell. Now comes the fun; Enter the following command:

passwd "your username"  
(no qoutes though)

If you are unsure of your username you can look at the names of the files in your home floder via:

cd /home

than enter


This will show you the names of users on your computer.

Now type the command I stated above; passwd "your username" without the qoutes. So that if your username is jane, I would type:

passwd jane

Next you will be presented with an option to enter your new unix password. This is where you enter the password. It will ask you to retype the command and then after two successful passwords were entered the password has been changed. Now log back into your system via


If you are asked for your root password when entering your new password this will usually help:

Second Possible Step

"If you get asked for the root password when entering single user mode use 'init=/bin/bash' on the kernel append line which should boot the machine into a bash console where you can get read/write access to your /etc/shadow file. You can then either run passwd or edit the shadow file directly to put in an empty string. This allows you to reboot the machine into its normal environment and login as root leaving the password blank and then run the passwd program to set the root password. This should really only be done when the machine is detached from any networks." (taken from shawn lee in an article mentioned below)

If you need more information these links can help:

share|improve this answer
The problem is, that he has the root password set, so he cannot drop to root shell unless he writes it. But he doesn't know it. – gajdipajti Apr 13 '12 at 20:35
Thanks, but the first step as mentioned is not working. I have tried the second option, but the screen remains blank after I edit grub and try to boot. The computer did not have critical data on it so I chose to format it at the end, it seemed the easiest way. – please delete me Apr 14 '12 at 1:40

If there is a root password set and you have forgotten it, but can boot normally and can use sudo try this from a terminal

sudo passwd -dl root

It is not apparent if you are getting the normal (and sudo) password and a root one confused.

The links you have for resetting passwd whould normally work.

share|improve this answer

Here. this might help How to reset your password in Ubuntu
or simply At your Grub menu, choose "Recovery Mode", then at the prompt type

passwd "your username" without quotes obviously

share|improve this answer

protected by Community May 31 at 5:55

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.