1

I accidentally ran the command:

sudo chown -R username:username *

on home directory (username = mili). Now I often have problems with group permissions when working on projects. Fix that work is to run:

sudo chgrp -R www-data project-name/

on every project. Is there way to fix this permanently other than reinstalling OS?

8
  • You already know how to fix it, so what is the problem?
    – fkraiem
    Jul 27, 2019 at 18:08
  • It's necessary to do it every time, I'm looking for a permanent solution.
    – Milomir
    Jul 27, 2019 at 18:12
  • For example, I create a few projects weekly (Laravel mostly). There is logs and cache folders witch dynamically create files. Whenever that happens I have to run this command because newly created files couses group permission errors.
    – Milomir
    Jul 27, 2019 at 18:18
  • Do you have the setgid bit set on the root of your project directory by any chance? if so, files created in it were possibly inheriting www-data group ownership previously - but are now inheriting your primary group Jul 27, 2019 at 18:23
  • I don't think so. Is this correct way to check, run "ls -ld", "ls -la" and look for 's'? If so, than no, there isn't seetgid bit.
    – Milomir
    Jul 27, 2019 at 19:03

1 Answer 1

0

I found a solution to the most troubling consequences.

Apache access problem solution (new files wasn't owned by the same group):

chgrp www-data ~/projects

chmod g+s ~/projects

Insufficient permission for .git/objects:

git config --global core.sharedRepository group

3
  • Sorry but you should not put files in you home under another name. Your home needs to be yours and some files need to be root. I would always put a website in its own directory with its own user and group
    – Rinzwind
    Aug 3, 2019 at 13:16
  • Why is that? As I see it, I'm still the owner, I just changed group so apache can handle it. Where do you put projects? I found it easy to be under home directory so I can regularly backup literally everything to an external drive.
    – Milomir
    Aug 3, 2019 at 19:20
  • I/We tend to use /opt/. Our projects are done by more than 1 person and we have 2 people that admin /opt/ It is also on a separate instance so it can be attached to different cloud instances. the reason for my comment is exactly what you did: if you mess up permissions in /home/ and you need to fix it you make life more difficult to fix it if there are more than your user ;)
    – Rinzwind
    Aug 3, 2019 at 21:20

You must log in to answer this question.

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