Re: How to replicate the behaviour of /usr/local
Klistvud <email@example.com> writes:
>Dne, 16. 10. 2009 12:19:03 je Cameron Hutchison napisal(a):
>> Klistvud <firstname.lastname@example.org> writes:
>> >I have a shared directory on my system; what I'd like to achieve is
>> >making every newly created (or copied from elsewhere) file belong to
>> >the group owner "users".
>> # chgrp users /path/to/shared/directory
>> # chmod g+s /path/to/shared/directory
>Thanx. Your solution, though, only works for newly created files. Files
>*copied to* my shared dir from elsewhere still retain their original
>group ownership(s)... That never happens in usr/local.
I think you need to look again and perhaps do some tests. What I
described is exactly how /usr/local is set up. I don't know what you are
doing wrong, but without you explaining exactly what you are doing,
no-one can really help you.
Let me demonstrate:
$ touch /tmp/testfile
$ ls -l /tmp/testfile
-rw-rw-r-- 1 camh camh 0 2009-10-17 09:24 /tmp/testfile
$ mkdir /tmp/shared
$ chgrp staff /tmp/shared
$ chmod g+s /tmp/shared
$ ls -ld /tmp/shared
drwxrwsr-x 2 camh staff 4096 2009-10-17 09:25 /tmp/shared
$ cp /tmp/testfile /tmp/shared
$ ls -l /tmp/shared/testfile
-rw-rw-r-- 1 camh staff 0 2009-10-17 09:26 /tmp/shared/testfile
Notice how the file /tmp/shared/testfile now has group "staff" where it
originally had "camh"?
Are you copying files into a directory nested underneath the top-level
shared directory? You need all your directories under your top-level
directory to be set up the same way. That is, the actual directory you
are putting files into needs to be set-group-id - higher levels in the
hierarchy do not matter.