1

While trying to restrict home folders to sudo users (then give a user access to one folder) I accidentally executed this command:

sudo chmod go-rwx /*/

Which removed access rights to all folders for all users, except the root account. I can't do anything currently on non-root accounts (no cd, ls, nano etc). How can I change folder permissions back to default where users had access to /home/ and program directories?

Note: I haven't really tried anything yet as I don't want to break things further.

2 Answers 2

1

About the only thing you can do is find out what the permissions were before and set them back. You might try installing another copy of Linux on a spare machine or VM to get the permission bits. Here are the permissions from one of my machines to get you started. Good luck.

cd /
chmod 1777 tmp
chmod 555 proc sys
chmod 700 lost+found
chmod 750 root
chmod 755 bin boot dev etc home lib lib64 media mnt opt run sbin share srv usr var
3
  • I managed to change all the folders to the permissions you said (they are the same my friend also has with a similar setup so they look right). Certain things don't appear to work properly, such has tabbing to auto complete, and most importantly, no new SSH connections can be established. I assume this is because some of the permissions or groups are wrong.
    – MikeS159
    Nov 18, 2016 at 11:21
  • Is it possible you changed permissions at more than just the root directory? Try running (as root) getfacl -R / >/var/tmp/perms on your friend's computer, copy /var/tmp/perms file to your machine, then cd /; setfacl --restore=/var/tmp/perms on your machine. This will copy the permission bits from all the files on his computer to yours. This won't be perfect, but it might get you further along.
    – virtex
    Nov 18, 2016 at 14:33
  • It just occurred to me that I didn't have you set the permissions on the root directory itself. Normally / has 755 permissions, so that would be chmod 755 /. Normally that wouldn't be affected by /*/ pattern, but it might if you have bash's dotglob setting enabled (shopt -s dotglob).
    – virtex
    Nov 18, 2016 at 14:37
0

I agree with @virtex and I furthermore recommend you, in case the permissions he shared with you didn't solved the issue, to try again writing the literal-additive form of the second argument in chmod and, in the worst of the cases, using the recursive -R option.

This is, as last choice use chmod -R u+rwx /lost+found instead of chmod 700 /lost+found (for example).

PS: It happened to me once that I changed permissions in / and then decided to solved the problem easy-peasy by reinstalling the whole system. But, of course, this is kind of a drastic solution...

2
  • I am thinking about re-installing the system, I'd just rather not have the hassle of re-installing all my software again.
    – MikeS159
    Nov 18, 2016 at 11:19
  • If you don't have your setting hyper-customized, go for it. You should feel cozy in less than 2 hours. Nov 18, 2016 at 14:18

You must log in to answer this question.

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