0

I was doing some alterations but in one I messed up.

I changed the permissions of almost everything inside the /usr folder to my own user. It didn't change everything because it failed in the middle of the execution, I still have /sbin, /share and /src assigned to root.

the command I ran was this (this was executed while inside /usr):

sudo chown -R myuser:myuser .

Is there any way for me to revert this?

If I run:

sudo chown -R root:root .

I get this error:

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

8
  • 1
    I would advice a re-install without formatting. – Rinzwind Jun 2 '14 at 19:21
  • That is what I'm thinking. But just before I go and do that I thought I'd come here for a better solution if there is one. – Rodrigo Sasaki Jun 2 '14 at 19:22
  • You should be able to fix this in a single user session by booting into recovery mode. See this document, follow the instructions to get a root prompt and remount your root partition as read-write, and then you should be able to cd /usr and chown -R root:root . – rocketman10404 Jun 2 '14 at 19:24
  • "Better" well... you could manually fix /usr/bin and /usr/bin/sudo and anything else that throws an error. But,unless you want to do that as a learning exercise, I would not waste time and just reinstall (without formatting) – Rinzwind Jun 2 '14 at 19:24
  • @rocketman10404 not everting in /usr/bin is root:root :) (chage is root:shadow bsd-write is root:tty crontab is root:crontab Not sure if it matters though ;) ) – Rinzwind Jun 2 '14 at 19:26
2

You cannot just chown -R the /usr partition, because not everything in that partition is owned by root. It sucks, you'll have to reinstall everything, but the only safe solution is to do a reinstall or recover from a backup.

1

It does suck to do a complete re-install. that is certainly one option. However, most of the files in /usr/bin ARE root:root. These are the only ones which aren't:

-rwsr-sr-x  1 daemon daemon     51464 Oct 21  2013 at
-rwxr-sr-x  1 root   shadow     54968 Feb 17 02:42 chage
-rwxr-sr-x  1 root   crontab    35984 Feb  9  2013 crontab
-rwsr-xr-x  1 root   lpadmin    14336 Apr 10 19:40 lppasswd
-rwxr-sr-x  3 root   mail       14592 Dec  3  2012 mail-lock
-rwxr-sr-x  3 root   mail       14592 Dec  3  2012 mail-touchlock
-rwxr-sr-x  3 root   mail       14592 Dec  3  2012 mail-unlock
-rwxr-sr-x  1 root   mlocate    39520 Jun 20  2013 mlocate
-rwxr-sr-x  1 root   ssh       284784 May 12 17:04 ssh-agent
-rwxr-sr-x  1 root   tty        19024 Apr 16 17:07 wall 

for a standard install. In /usr/sbin it's:

-rwsr-xr--  1 root    dip      343168 Jan 22  2013 pppd
-rwsr-sr-x  1 libuuid libuuid   18904 Apr 16 17:07 uuidd

in /usr/lib/

drwxr-xr-x   2 root utempter     4096 May  7 23:46 utempter

in /usr/local/share

 drwxrwsr-x  2 root staff 4096 Aug 20  2013 ca-certificates
 drwxrwsr-x  2 root staff 4096 Aug 20  2013 fonts
 drwxrwsr-x  7 root staff 4096 May  8 17:11 sgml
 drwxrwsr-x  6 root staff 4096 May  8 17:11 xml

and in /usr/local/lib any python directories, e.g:

 drwxrwsr-x  4 root staff 4096 May  8 18:44 python2.7
1
  • obviously if you have installed lots of additional software, there may be others - but if you re-install without formatting it won't fix those anyway – Nick Veitch Jun 2 '14 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.