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.