Recently I had to change the folder permissions of /usr
folder. Now the whole sudo
is not working. If I try to update my system using this command:
sudo apt-get update
I get the following message:
sudo: /usr/lib/sudo/sudoers.so must be only be writable by owner
sudo: fatal error, unable to load plugins
So I tried to change the folder permissions by opening Nautilus as root by using this command
gksudo nautilus
But nothing happened. Nautilus didn't open. This is an emergency as the whole of sudo
is not working. when I tried searching the solution from Google many suggested re-installation. I don't prefer re-installation. so is there any other solution?
Best Answer
There are actually two mechanisms set up in Ubuntu for performing administrative tasks.
sudo
is one of them, and it and its graphical frontends (likegksu
andgksudo
) are not going to work until you fix the permissions problem.The other mechanism is PolicyKit. Depending on exactly what you have done to your file permissions, it's likely that you can still recover using PolicyKit to run commands as
root
.The
pkexec
command will run any (nongraphical) command asroot
(provided that the user invoking it is an administrator on the system).pkexec
is capable of running graphical commands (likenautilus
) asroot
, too, but this is quite nontrivial, as you have to set up configuration files for them describing how they are supposed to be run and what they are supposed to be allowed to do. Therefore, you're best off using the command-line to fix this problem...at least to the point wheresudo
works again. (Then you can rungksu nautilus
to get aroot
file browser, if you're more comfortable using that to edit file permissions recursively.)I don't know exactly what you did to your permissions, so it's hard for me to give you a specific
pkexec
command to run, to fix the problem. But you can rectify the specific problem thatsudo
is currently complaining about. It says:So remove
group
andother
write permissions (while not modifyingowner
write permissions) for that file:Then you can see if
sudo
works (by running some innocuous command likesudo ls
).If you need to perform other operations on file permissions from the command-line with
chmod
, seeman chmod
.(By the way, here's another, related situation where it's handy to know about
pkexec
.)If you have trouble getting
pkexec
to work for this, please feel free to comment here, and I'll try to render further assistance. But you should know that even if this method does not work, you shouldn't have to reinstall Ubuntu.Instead, you can fix the problem from an Ubuntu live CD/DVD or live USB system, because the live system will be functioning--
sudo
will work on it--and you can mount your Ubuntu partition and change the permissions that way.Or as a third option (as forestpiskie has suggested), you could use recovery mode.