7

So, I did a stupid thing...

I was installing some software (Java SE 7, if you must know) from a tarball, and I got tired of using sudo, so I went and changed the owner of my /usr directory to myself.

$ sudo chown -R sammy /usr

Whoops!

Since sudo lives in /usr/bin/, it also changed owner. Now, I can't use it anymore. Have I accidentally been caught in a sudo-Catch 22? I can't use apt-get install or any number of other essential features of my shell environment.

$ sudo
sudo: must be setuid root

Is there a way to change the owner of this directory (and subdirectories, too) back to root?

2 Answers2

5

Restart the machine, boot into recovery (you should end up being root without having to type in any password). Proceed to chown -R. I think it should work. Report back on how it goes.

Wolfer
  • 2,174
4

Man, you really did it, all /usr have almost essentials binaries, but lets repair your sudo first:

As root in the recovery console, you should remount the filesystem as read/write first:

chown root:root /usr/bin/sudo
chmod u+s /usr/bin/sudo

Then reboot and try to login, if you get more "Must be suid" errors repeat the process using sudo from the tty:

sudo chmod u+s /path/to/the/binary/you/screwed

Be careful next time and try to use -R --recursive with baby gloves.

Braiam
  • 67,791
  • 32
  • 179
  • 269