I often find myself chown-ing files as I created them through SSH and they are owned by jm:jm
for example.
Then to allow Apache to access it, I need to for example do chown jm:www-data
.
I am sure I can specify that when I create files, instead of using the group under my name, specify another?
Or is there a better way of managing users/groups?
Best Answer
If you want all new files in a particular directory to be owned by a particular group, just apply the
setgid
bit on it:If you have an existing tree of directories that you want to apply this behaviour to, you can do so with
find
:(if the directories are already owned by the relevant group, then you can omit the first command in both of these examples).