-2

I've just come into the following problem:

For some reason I can't use su or sudo:

usr@usr-MS-7816:~$ su
Password: 
su: Authentication failure
usr@usr-MS-7816:~$ sudo su
[sudo] password for usr: 
usr is not in the sudoers file.  This incident will be reported.
usr@usr-MS-7816:~$ 

I could use sudo su earlier. Maybe it's because I assigned another group to myself, I don't really know. I also tried entering Recovery mode and I could login as root but it doesn't allow me to change /etc/passwd or /etc/sudoers files (it says that they're read-only)! What am I supposed to do now?

It's Ubuntu 15.04

2

1 Answer 1

1

Promoting a comment to an answer: To quickly solve your problem, you should probably just try following the advice from our sister site, AskUbuntu, on how to reset your root (admin) password, which should cover you

Taking your question in detail, to explain what went wrong...

usr@usr-MS-7816:~$ su
Password: 
su: Authentication failure

This would seem to suggest that either you've forgotten your root password, or never set one during the installation.

usr@usr-MS-7816:~$ sudo su
[sudo] password for usr: 
usr is not in the sudoers file.  This incident will be reported.

Without being root, you won't be able to check /etc/sudoers and the contents of /etc/sudoers.d to see what the sudo rules are for your system. That means you can't immediately see what you've done wrong. It could be that you're not in a suitable group, or it could be that you don't have any user or group based rules in your sudo config to permit sudo to root. There are quite a few good sudo tutorials out there, once you're back into the system I'd suggest you review them + decide if you want to enable sudo by group or by user, then add the relevant sudo lines / add yourself to the right group.

Finally, you said:

I also tried entering Recovery mode and I could login as root but it doesn't allow me to change /etc/passwd or /etc/sudoers files (it says that they're read-only)

What you'll need to do is boot into recovery mode, then enable read-write access to your filesystem.

As covered in the answer on AskUbunut, once you've got the terminal up in recovery mode, you'll want to do something like:

mount -rw -o remount /
passwd
sync
reboot

That'll re-mount the root partition read-write, so you can change it. You then change the root password (as root you don't need to enter the previous one), then sync to force the changes out to disk, before you shutdown+reboot back to normal mode where you can access root with the new password

Not the answer you're looking for? Browse other questions tagged .