2

Basically was trying to change the ushare config and needed permissions for some reason so, I changed with sudo -i and in the process did somthing and now I can't access superuser to change any of the permissions.

Also it says /etc/sudoers is mode 0660, but should be 0440 in the Terminal when I try and access it.

What can I do?

Eliah Kagan
  • 117,780
Alec
  • 21

1 Answers1

2

You've changed the permissions of one or more of sudo's configuration files. Because the files could potentially lead to major insecurity on some systems with the wrong permissions, sudo refuses to work at all unless their permissions are set correctly. Since sudo will not work, you cannot use it to become root (the superuser) to fix them.

However, there are actually two mechanisms used on a desktop Ubuntu system to perform actions as root: sudo, and PolicyKit. PolicyKit provides a command that you can use to run run non-graphical programs as root, similar to sudo: the pkexec command.

If your problem is that the file /etc/sudoers has the wrong permissions, you can fix this with:

pkexec chmod 440 /etc/sudoers

Then you should be able to use sudo again. (You can try running a harmless command like sudo ls to find out.)

If there are files in /etc/sudoers.d that have the wrong permissions, you may have to set their permissions correctly, in a similar manner. Or just do it for all of them at once:

pkexec chmod 440 /etc/sudoers.d/*

(Even the README file in there is required to have these restrictive permissions, so there should be no problem using that command. However, you likely don't need it, if it's just /etc/sudoers itself that got the wrong permissions.)

See also this related question.


You might have been tempted to change the permissions of /etc/sudoers or of a file in /etc/sudoers.d to edit it. You should not do this, and you do not need to. In the future, you should use visudo to edit these files instead. That does so safely, and prevents the problem you are now experiencing.

Eliah Kagan
  • 117,780