1

This is for an Ubuntu 15.04 on a laptop (Dell inspiron 3135).

Somehow the capability to use sudo got lost, and, probably relatedly, I can no longer log in at the lock screen. There is no problem logging in after a reboot. But I can no longer make software updates if they require root privilege; when trying to authenticate with my user password the dialog window "shakes its head" and the request is denied. So I have to cancel software updates.

Here is what I've tried so far:

Since I obviously can't use sudo for anything I booted the system up in recovery mode and used the <drop to root shell> menu item. Then I get a prompt

root>

I then mount the / partition using

mount -o rw,remount /

And then tried first (let's just say my login is wuzzle)

usermod -a -G sudo wuzzle

Then rebooted, logged on and find that I still couldn't use sudo

Next I tried, after the same procedure as above,

adduser wuzzle sudo

This command, as the previous one, was accepted without response.

Yet, after reboot and login I still can't sudo. For example:

ls -l  /etc/sudoers

shows it has this ownership

-r--r------1 root root

Further, trying

cd /etc/; more sudoers

gives

sudoers permission denied

and

$ sudo more sudoers
[sudo]password for wuzzle: (password entered)
Sorry, try again. 

Also, the date of the file /etc/sudoers indicates that it was unchanged even though I used before commands (as root) that I had expected should change the file.

Now I'm out of ideas. I tried to find a solution by searching and browsing around but it appears that everything written about similar problems always gives advice using commands that require sudo. So it's all catch 22.

Later added:

I also tried to use the same commands again (from the root shell in recovery mode):

> adduser wuzzle sudo
The user wuzzle is already a member of `sudo`.

But that's not true.

1

From your description, the account password itself isn't correct (the dialog window "shakes its head"). If this is the case, resetting your password with the rescue prompt should fix it.

  • Thank you for this hint. It was not the reason but it lead to finding the reason: Nothing was wrong with sudo, but my keyboard map was messed up (did not notice I was using Japanese keyboard layout the whole time which became default immediately after the window system is fired up. So i could log in initially every time but after that the none letter characters I typed where not the same as what the system received) – Reiner Jun 13 '15 at 15:37
  • What a beartrap! Glad it is solved. – Max Lemieux Jun 13 '15 at 17:59
1

As per your comment, the reason for this was that your system was set to a different keyboard layout to the one you expected. I've run into that problem too. The keyboard shortcut to switch layout should work fine at the lock screen.

I'm mainly writing this answer to correct a few misconceptions in your question.

Max Lemieux's answer points out that the problem here was that you were typing the wrong password (not because you were making a mistake of course, but because you were typing on the wrong layout and had no way of knowing that because nothing shows up when the password is typed) and that is clear from the error you show:

$ sudo more sudoers
[sudo]password for wuzzle: (password entered)
Sorry, try again.

This error just means the wrong password was entered.

You showed in your question your repeated efforts to fix this by adding yourself to the sudo group. You even accused Bash of lying to you when it said you were already in the sudo group(!) The commands you used to add yourself to the sudo group were correct, and you noticed that they returned no errors. If you had not been in the sudo group, this is what would have happened when you tried to use sudo:

$ sudo uname -r
[sudo] password for unicorn: 
unicorn is not in the sudoers file.  This incident will be reported.

You could have checked what groups you were in on the command line without needing sudo, using, for example, these commands:

$ groups
zanna adm cdrom sudo dip plugdev lpadmin sambashare
$ id
uid=1000(zanna) gid=1000(zanna) groups=1000(zanna),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),130(sambashare)

You also said this

Yet, after reboot and login I still can't sudo. For example:

ls -l  /etc/sudoers

shows it has this ownership

-r--r------1 root root

That's exactly what it should be, and if those ownerships and those permissions are changed, sudo will refuse to work very stubbornly until they have been fixed (of course you will need to somehow get a root shell to fix it because you won't be able to use sudo). You should never change the permissions of the sudoers file.

Also, the date of the file /etc/sudoers indicates that it was unchanged even though I used before commands (as root) that I had expected should change the file.

Adding a user to the sudo group does not change the sudoers file. If you examine the file, you will see how it is that adding a user to the sudo group gives them access to sudo:

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

So, no need for a line about each user - this one line plus group membership gives you all the privileges you'll need. As far as I know, the sudoers file is never edited automatically.

If you ever do need to edit /etc/sudoers, be sure to use sudo visudo which won't let you save the file if you've introduced syntax errors.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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