0

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?

20
  • 1
    Did you run the chmod command with -R?
    – edwinksl
    Sep 7, 2016 at 19:52
  • 3
    Having no password for root is not the same as having no root access: quite the opposite, in fact. You should be able to drop directly to a root shell from Recovery Mode and run chmod from there. Sep 7, 2016 at 19:55
  • 2
    If you only did chmod 666 /usr there's no reason bin should have changed. Do what @steeldriver suggested and use Recovery (enter through GRUB). Sep 7, 2016 at 20:00
  • 2
    DO NOT cd usr chmod 755 * - that will make things MUCH worse Sep 7, 2016 at 20:03
  • 1
    @TonyLancer if you use -R here you may as well reinstall, please read up!
    – Zanna
    Sep 7, 2016 at 20:06

2 Answers 2

4

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

  1. Boot into recovery mode via the grub advanced menu and select 'Drop to root shell'
  2. Remount the filesystem in read-write mode

    mount -o remount,rw /
    
  3. Execute the command

    chmod 755 /usr
    

    Don't add any other command line options and don't use any shell wildcards.

  4. Type exit to 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.

-1

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/sudo

You 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
  • 2
    this is wrong, the permissions of /usr/bin/sudo have not been changed - OP's problem is that the /usr directory (parent of sudo) has no execute permissions
    – Zanna
    Sep 7, 2016 at 20:18
  • thx, i saw your comment regarding the folder-rights which are not set to executeable. This should be fixed at first.
    – Mick
    Sep 7, 2016 at 20:23
  • The setuid bit on /usr/bin/sudo would only be cleared if OP used -R flag on chmod command, which they did not. If they had done so, their problems would be much worse than not having sudo
    – Zanna
    Sep 7, 2016 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .