I have made a big mistake and now I cannot do anything in my work station. I tried to start VirtualBox and it complained that /usr had execution access. Then I executed, wrongly, sudo chmod 666 /usr and now I cannot execute 'sudo' anymore.
I have asked our technical department and they say that Ubuntu has no password for root so they cannot see any solution for my error but reinstall again Ubuntu which means I would lose all my work.
I hope any of you can think of a solution for this problem because. What do you think I should do to gain access again in the /usr or become root user?
202 Answers
If you just did sudo chmod 666 /usr then things are no too bad - since that will have changed the permissions only on the parent /usr directory, not any of the files of subdirectories within it.
If however you added the recursive flag -R then you are almost certainly better off re-installing the system. Even so, there should be no reason to lose data: you can boot from a live USB or DVD and backup your important files from there first.
If you only did a non-recursive sudo chmod 666 of the /usr directory, and you have physical access to the machine, then the simplest fix should be
- Boot into recovery mode via the grub advanced menu and select 'Drop to root shell'
Remount the filesystem in read-write mode
mount -o remount,rw /Execute the command
chmod 755 /usrDon't add any other command line options and don't use any shell wildcards.
Type
exitto continue booting normally
Note, chmod lives in /bin rather than /usr/bin so shouldn't be affected by the permissions on /usr. If (for example) you'd change the permission bits on the /bin directory, or on the / directory itself, then this method would not be appropriate since you wouldn't be able to execute chomd from recovery mode - the best option in that case would probably be to boot a live CD/DVD/USB of any available Linux distribution (it doesn't need to be Ubuntu); identify and mount the broken system's root device (at /mnt in the live system, for example); and then run chmod 755 /mnt/usr from the live system.
Your command had possibly removed the SUID-Bit from /usr/bin/sudo The correct permissions should be:
-rwsr-xr-x 1 root root 136808 Aug 17 15:20 /usr/bin/sudoYou should get a recovery-cd, as mentioned in die comments above and follow the steps in section "finding your root partition". After you successfully mounted it set the SUID-Bit with : chmod 4755 /usr/bin/sudo
3