Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
    
thank you very much –  Alec Jun 17 '12 at 20:30
1  
@Alec If this worked for you, you should consider marking it as the accepted answer. –  Eliah Kagan Jun 17 '12 at 20:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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