1

First, I ran:

sudo chmod -R -777 /usr 

Now, my /usr dir permissions looks like this:

d---------

So nobody has permissions I can't even get in the dir or run bash commands.

14
  • 1
    Did you run something like chmod on /usr?
    – Kulfy
    Nov 3, 2019 at 17:33
  • 4
    -777=000. The command you used changed the permissions of /usr and all subdirectories and files in /usr to 000 recursively. It's hard to replicate the original schema of /usr. I think OS reinstallation is the only solution unless somebody else can replicate the exact permissions of files and sub-folders of /usr
    – Kulfy
    Nov 3, 2019 at 17:47
  • 3
    I agree with Kulfy. Re-install w/o formatting is the quickest way to get a working system. And please don't do that again "Now, my /usr dir permissions looks like this: d---------" that is exactly what you asked it to do ;-)
    – Rinzwind
    Nov 3, 2019 at 17:53
  • 1
    @mchid Right. /usr has 755. But what about the files in it? For example: /usr/bin/sudo has -rwsr-xr-x, /usr/include/glob.h has 644. IMO this can't be achieved in one shot. Remember permissions were changed recursively
    – Kulfy
    Nov 3, 2019 at 17:57
  • 1
    all the different permissions I have in /usr (this command took several minutes to run)
    – Zanna
    Nov 3, 2019 at 18:10

1 Answer 1

1

This shows all the different file permissions in /usr, that you'd have to change back:

walt@bat:~(0)$ sudo find /usr -xdev -print0 | xargs -0 -r -n 1000 sudo stat --format="%A" | sort | uniq -c | sort -rn
 440550 -rw-r--r--
  86783 lrwxrwxrwx
  51877 drwxr-xr-x
  16293 -r--r--r--
   8060 -rwxr-xr-x
   1174 drwxrwxr-x
    461 -rw-rw-r--
    363 -r-xr-xr-x
     28 -rwxrwxr-x
     22 drwxrwsr-x
     17 -rwxr-sr-x
     16 -rwsr-xr-x
      6 -rwxr--r--
      4 -rwsr-sr-x
      2 -r-xr-sr-x
      2 -r-xr--r--
      2 -rwsr-xr--
      1 -rwxr-xr--
      1 -rwx------
      1 drwxrwsr-t

This shows all the permissions AND ownerships in /usr that you would have to change back:

walt@bat:~(0)$ sudo find /usr -xdev -print0 | xargs -0 -r -n 1000 sudo stat --format="%A %U:%G" | sort | uniq -c | sort -rn
[sudo] password for walt: 
 440517 -rw-r--r-- root:root
  86783 lrwxrwxrwx root:root
  51870 drwxr-xr-x root:root
  16293 -r--r--r-- root:root
   8058 -rwxr-xr-x root:root
   1174 drwxrwxr-x root:root
    461 -rw-rw-r-- root:root
    363 -r-xr-xr-x root:root
     33 -rw-r--r-- walt:walt
     28 -rwxrwxr-x root:root
     22 drwxrwsr-x root:staff
     16 -rwsr-xr-x root:root
      6 -rwxr-sr-x root:mail
      6 -rwxr--r-- root:root
      6 drwxr-xr-x walt:walt
      3 -rwxr-sr-x root:tty
      2 -r-xr-sr-x root:postdrop
      2 -r-xr--r-- root:root
      2 -rwxr-xr-x walt:walt
      2 -rwxr-sr-x root:utmp
      2 -rwxr-sr-x root:shadow
      2 -rwsr-sr-x root:root
      1 -rwxr-xr-- root:wireshark
      1 -rwxr-sr-x root:ssh
      1 -rwxr-sr-x root:mlocate
      1 -rwxr-sr-x root:games
      1 -rwxr-sr-x root:crontab
      1 -rwx------ root:root
      1 -rwsr-xr-- root:messagebus
      1 -rwsr-xr-- root:dip
      1 -rwsr-sr-x root:mail
      1 -rwsr-sr-x daemon:daemon
      1 drwxr-xr-x walt:root
      1 drwxrwsr-t root:lpadmin

You have stirred your system with a root stick. It's broken. Reinstall, and don't do that.

1
  • The following answer (in the comments) explains how to install without formatting so that you can maybe keep your home directory. However, you should always make a backup just in case, of course. askubuntu.com/a/270045/167115
    – mchid
    Nov 3, 2019 at 18:26

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