I changed the permission of the /usr
to 400 and now I am not able to use sudo
. How do I revert this and fix it?

- 70,465
3 Answers
Well - so you made /usr readable only to root, I guess (if no further changes). More over - you removed "x" by that which made the folder pretty much not accessible. Hence you can't now - as regular user - run sudo, which, if I remember correctly, is in /usr/bin/.
The best idea for now would be to start a system from LiveCD, mount your disk/filesystem and change the permissions back to 755.
And next time to be more careful with this kind of changes ;)

- 1,911
- 12
- 10
If you have things resolved, assign a password to the root user so you can login directly as root should you ever need to.
-
1There is no need to change the default security settings. root should be disabled. For things like this you use grub rescue or a live session. – Rinzwind Apr 22 '17 at 20:21
-
I agree Rinzwind. The same should be said about changing permissions on system directories. My suggestion should really be applied with care. – Apr 22 '17 at 20:44
I remember that I got a similar problem a few years ago, and the solution was not trivial. You can always recover the sudo
command, but, if you changed the permission of all the /usr/
sub-files, since you don't know the exact permission of all the files you changed, you may choose bad/dangerous configuration which would lead you to an unstable system. Maybe doing a re-installation would be better... But if you really want to try to recover your system, or if you didn't recursively changed the /usr
permision, you have the following option.
Try #1: Connect as root if the account is enabled (quick to test, but likely to fail)
If you have the root password enabled, you are lucky, just log as root
su root
<enter root password>
chmod 755 /usr
and if all sub files have bad permission (it's may lead to an unstable system) :
chmod -R 755 /usr
Try #2: Boot in recovery mode (do not need USB Key, but likely to fail)
You may want to try to boot in recovery mode, just hit "Escape" or "Shift" when you reboot, and you will get a root. You will be then able to type
chmod 755 /usr
However this method does not always work, depending on how you configured the passwords...
Try #3: Use a LiveUSB (always work)
Take an empty USB key, download a live ubuntu system, copy the system on it by using Unebootin for example, or if you know what you are doing with dd if=<fichier>.iso of=/dev/sdX bs=4M
. Boot on the USB key, and then run
sudo mkdir /mnt/drive
sudo mount /sdXn /mnt/drive
cd /mnt/drive
ls # Check that you see usr...
sudo chmod 755 /usr/

- 2,448
-
Please don't recommend
chmod -R
when you're not completely sure what you're doing.chmod -R 755 /usr
will ruin things likesudo
. – Chai T. Rex Apr 22 '17 at 20:15 -
I already explained that -R should be avoided, but if the user broke already everything with another chmod -R, everything is already broken, so it cannot be worse. That's why I recommend first a reinstall. – tobiasBora Apr 24 '17 at 23:13
chmod 0400 /usr
with the-R
option you can easily recover from the situation with recovery mode andchmod 0755 /usr
. – David Foerster Apr 22 '17 at 22:38