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.

mchid
  • 42,315
  • 7
  • 94
  • 147
  • Are you using 14.04 or Kali? – Kulfy Nov 03 '19 at 17:26
  • 18.04, already change it – Daniel Silva Nov 03 '19 at 17:32
  • 1
    Did you run something like chmod on /usr? – Kulfy Nov 03 '19 at 17:33
  • yes u did, something like sudo chmod -R -777 /usr – Daniel Silva Nov 03 '19 at 17:34
  • 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 03 '19 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 03 '19 at 17:53
  • @Kulfy If I'm not mistaken, `/usr` is all `755`. If there is any way to change to `755` you will be good. – mchid Nov 03 '19 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 03 '19 at 17:57
  • @mchid no -but- those that are 644 might not mind being 755 Kulfy in 2 you can set 755 for dirs and 644 for files but it is a system directory. I would still just reinstall w/o a format. Probably the easiest method with the most desired result – Rinzwind Nov 03 '19 at 17:58
  • I will agree with the reinstallation is the best steps for this. Yes, the folder of `/usr` is 755, however, there is a lot of SUIDs and other special permissions of files in that folder and the subfolders that need to be set. – Terrance Nov 03 '19 at 17:58
  • Possible duplicate of [Set myself as owner of /etc with chown command now getting all kinds of errors](https://askubuntu.com/questions/300641/set-myself-as-owner-of-etc-with-chown-command-now-getting-all-kinds-of-errors) (see [terdon's answer](https://askubuntu.com/a/884657/527764) and [What if I accidentally run command chmod -R on system directories](https://askubuntu.com/questions/43621/what-if-i-accidentally-run-command-chmod-r-on-system-directories) – Zanna Nov 03 '19 at 17:59
  • @Rinzwind I now see there is a lot of `lib` files that are not 755. Re-install without formatting is probably best. At least you get to keep the home directory. – mchid Nov 03 '19 at 17:59
  • @mchid indeed but those all seem to be 644. That is easily set with a find (1 for dirs, 1 for files). – Rinzwind Nov 03 '19 at 18:00
  • 1
    [all the different permissions I have in /usr](https://paste.ubuntu.com/p/TcXhRQ9YBh/) (this command took several minutes to run) – Zanna Nov 03 '19 at 18:10

1 Answers1

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.

waltinator
  • 35,099
  • 19
  • 57
  • 93
  • 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. https://askubuntu.com/a/270045/167115 – mchid Nov 03 '19 at 18:26