Root password

2 views
Skip to first unread message

Bill Stanley

unread,
Mar 12, 2012, 12:21:05 PM3/12/12
to Ubuntu user technical support, not for general discussions
Hi,

Is there any to reset the root password when the original root password
has been forgotten? One of my friends has Ubuntu an her computer and
was trying to change her user password. She got the root and user
passwords mixed up and somehow changed the root password instead. She
doesn't know what she did and the important thing is that the root
password is lost.

Of course, the root password is needed to install applications, run sudo
and to di upgrades. I know that there is no way to recover the password
but is there a way to reset the root password without knowing what it
is. Without it, the computer can't be upgraded. I could try to
reinstall Ubuntu but many of her settings would be lost and that would
be a PITA as well.

Bill Stanley

--
ubuntu-users mailing list
ubuntu...@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

Jeffrey Gray

unread,
Mar 12, 2012, 12:30:48 PM3/12/12
to bst...@wowway.com, Ubuntu user technical support, not for general discussions
If she is a sudoer, she can 'sudo passwd root'.

FYI...By default, root is disabled and not able to be logged into
until a sudoer sets the passwd.

-Jeff Gray

Gilles Gravier

unread,
Mar 12, 2012, 1:07:16 PM3/12/12
to ubuntu...@lists.ubuntu.com, bst...@wowway.com
Hi, Bill!

On 12/03/2012 17:21, Bill Stanley wrote:
> Hi,
>
> Is there any to reset the root password when the original root
> password has been forgotten? One of my friends has Ubuntu an her
> computer and was trying to change her user password. She got the root
> and user passwords mixed up and somehow changed the root password
> instead. She doesn't know what she did and the important thing is
> that the root password is lost.

Actually, there is no "original root password" on Ubuntu. See below.


> Of course, the root password is needed to install applications, run
> sudo and to di upgrades. I know that there is no way to recover the
> password but is there a way to reset the root password without knowing
> what it is. Without it, the computer can't be upgraded. I could try
> to reinstall Ubuntu but many of her settings would be lost and that
> would be a PITA as well.
>

No it isn't. You run these commands from the account of an administrator
user. And use that user's password to authenticate, and since the user
is administrator, they can run these commands.

If logged in as user "scott" with password "tiger" (my old days of
learning to use Oracle - default user passwords), and you want to run a
system update,
you would "sudo apt-get update" and when prompted for your password, you
would just enter "tiger".

You never NEED a root password on a normal Ubuntu system, unless running
VERY OLD stuff badly writte.

Now if you want to SET a root password, you can always "sudo passwd
root". You will be prompted (by sudo) for your administrator user
password, and then you will be able to set a root password.

But this is unsafe. With root as a directly accessible user, you lose
auditability. Whereas if you "sudo SomeAdminTask", then there is a log
of which user launched "SomeAdminTask"...

Gilles.

Rashkae

unread,
Mar 12, 2012, 2:13:02 PM3/12/12
to bst...@wowway.com, Ubuntu user technical support, not for general discussions
On 03/12/2012 12:21 PM, Bill Stanley wrote:
> Hi,
>
> Is there any to reset the root password when the original root
> password has been forgotten? One of my friends has Ubuntu an her
> computer and was trying to change her user password. She got the root
> and user passwords mixed up and somehow changed the root password
> instead. She doesn't know what she did and the important thing is
> that the root password is lost.
>
> Of course, the root password is needed to install applications, run
> sudo and to di upgrades. I know that there is no way to recover the
> password but is there a way to reset the root password without knowing
> what it is. Without it, the computer can't be upgraded. I could try
> to reinstall Ubuntu but many of her settings would be lost and that
> would be a PITA as well.
>
> Bill Stanley
>

In a default install of Ubuntu, there is no root password. If this is
the case, the Ubuntu recovery Boot will get you to a shell with root access.

When booting the system, press and hold the Shift Key to force the Grub
menu to appear, from there, choose the Recovery Mode option. (Note: for
some reason, on my test system, as well as holding the Shift key during
boot, I have to press the ESC key when the "Grub Botting" message
appears to bring up the menu.)

If root account really is password locked and you can not open it this
way, you have to modify the boot parameters. (This is the ultimate
Linux password recovery that will work on any Linux distro as long as
the Hard drive is not encrypted.)

Again, you have to get to the Grub Menu. Press the 'e' key to Edit the
default boot options. Use the arrow keys to get to the end of the
"linux" line. This usually ends with 'ro quiet splash.' (It probably
wraps into two lines of text on your screen, but it's really all 1
line.) Delete the 'quiet splash' and replace them with 'init=/bin/sh'
Press Ctrl-X to boot.

That should dump you into a very basic command shell. Now type
'/usr/bin/passwd root" to change the root password.

Basil Chupin

unread,
Mar 12, 2012, 6:14:08 PM3/12/12
to ubuntu...@lists.ubuntu.com
On 13/03/12 03:21, Bill Stanley wrote:
> Hi,
>
> Is there any to reset the root password when the original root
> password has been forgotten? One of my friends has Ubuntu an her
> computer and was trying to change her user password. She got the root
> and user passwords mixed up and somehow changed the root password
> instead. She doesn't know what she did and the important thing is
> that the root password is lost.
>
> Of course, the root password is needed to install applications, run
> sudo and to di upgrades. I know that there is no way to recover the
> password but is there a way to reset the root password without knowing
> what it is. Without it, the computer can't be upgraded. I could try
> to reinstall Ubuntu but many of her settings would be lost and that
> would be a PITA as well.
>
> Bill Stanley

I know that your question has already been answered, but the next time
try doing a search on the web - you will find thousands of entries
telling you how to solve this problem :-) .

BC

--
The vulgar crowd always is taken by appearances, and the world consists chiefly of the vulgar.
Niccolo Machiavelli

Rashkae

unread,
Mar 12, 2012, 6:18:06 PM3/12/12
to bst...@wowway.com, Ubuntu user technical support, not for general discussions
On 03/12/2012 04:23 PM, Bill Stanley wrote:
>
> Now we are getting somewhere! However, I didn't actually mean the
> root password. Is the administrator password you need to sudo
> commands the same as the root password? It looks as if it is. If it
> isn't, how do I change it without knowing the old one which was lost?
>
> Bill Stanley
>

In a default Ubuntu install, the 'administrator' is the first user, and
the password used by sudo is the same password you use to log in.

You need the know the username of this account. If you are locked out
of the account and need to recover with the root shell as I described,
then you can use /usr/bin/passwd <username> to change the password for
that username.

If you don't know the username of the adminstrator account, then you
need to find it. Use /usr/bin/less /etc/group and look in the group
file to see what usernames are part of the 'admin' or 'sudo' group
(sorry, I'm not sure which Ubuntu uses)

Rashkae

unread,
Mar 12, 2012, 7:09:51 PM3/12/12
to Ubuntu user technical support, not for general discussions
On 03/12/2012 06:26 PM, Bill Stanley wrote:
>
> Wonderful! But don't I need to know the sudo password? This sounds
> like it is sudo stuff to me. Does booting into the recovery mode
> allow me root access?
>
>
> Bill Stanley
>
The Ubuntu Recovery option should give you root access. Changing
init=/bin/bash (I said /bin/sh in my original message, but in Ubuntu,
you probably want to use bash) completely bypasses any kind of login.

Please reply to list. Aside from being good netiquette, that will also
allow others to review the conversation. I'm prone to careless errors.

Bill Stanley

unread,
Mar 12, 2012, 9:31:28 PM3/12/12
to Ubuntu user technical support, not for general discussions
On 03/12/2012 07:09 PM, Rashkae wrote:
> On 03/12/2012 06:26 PM, Bill Stanley wrote:
>>
>> Wonderful! But don't I need to know the sudo password? This sounds
>> like it is sudo stuff to me. Does booting into the recovery mode allow
>> me root access?
>>
>>
>> Bill Stanley
>>
> The Ubuntu Recovery option should give you root access. Changing
> init=/bin/bash (I said /bin/sh in my original message, but in Ubuntu,
> you probably want to use bash) completely bypasses any kind of login.
>
> Please reply to list. Aside from being good netiquette, that will also
> allow others to review the conversation. I'm prone to careless errors.

I'll let you know how it goes but it might not be anytime soon. I don't
go to her house often and since it's not an emergency, I'll not go soon.
(She is just a good friend.) Your solution does look promising.

One more question... You mentioned grub but she does not dual boot.
Ubuntu is the only operating system on her machine. Do I follow the
same steps to get to Recovery Mode? Maybe the original installation
disk will help?

Bill Stanley

Jeffrey Gray

unread,
Mar 13, 2012, 12:15:19 AM3/13/12
to bst...@wowway.com, Ubuntu user technical support, not for general discussions
Worse case scenario if you don't have the password for anyone in the
sudoers list, just boot on a live CD/flash and copy the /home off to
an external or network drive.

Rashkae

unread,
Mar 13, 2012, 12:38:04 AM3/13/12
to ubuntu...@lists.ubuntu.com
On 03/12/2012 09:31 PM, Bill Stanley wrote:
>
> One more question... You mentioned grub but she does not dual boot.
> Ubuntu is the only operating system on her machine. Do I follow the
> same steps to get to Recovery Mode? Maybe the original installation
> disk will help?

Actually, the steps I mentioned were assuming a single boot system. If
Windows (or any other OS) were installed, Grub would always display the
boot menu and there would be no need to monkey with Shift and ESC key to
reveal it.

Linux needs a bootloader to boot, regardless of whether or not that
bootloader also juggles other OS's. (Technically, that's not true, but
for all intents and purposes, it might as well be and will suffice for
today.) Of the two commonly used bootloaders for Linux, LILO and GRUB,
just about all modern distros now use GRUB or GRUB2 by default.

One of the nice things about a full working grub install with menu is
that it makes it easy to modify the parameters that the kernels starts
with, which is what I documented here.

However, I should point out, as all too often happens on this list, I
foolishly re-hashed data that is already much better covered by the
friendly Ubuntu documentation.

https://help.ubuntu.com/community/LostPassword

I can already see that one critically important detail I had overlooked
in my explanation. If you are using the init=/bin/bash method, you have
to change the 'ro' in the kernel boot parameters to 'rw' (You won't be
able to change the password so long as the filesystem is mounted
Read-Only rather than read-write.)

Gilles Gravier

unread,
Mar 13, 2012, 1:33:33 AM3/13/12
to ubuntu...@lists.ubuntu.com
Hi!

On 13/03/2012 05:15, Jeffrey Gray wrote:
> Worse case scenario if you don't have the password for anyone in the
> sudoers list, just boot on a live CD/flash and copy the /home off to
> an external or network drive.

Not if her home is encrypted...

Gilles

Reply all
Reply to author
Forward
0 new messages