Make new user sub-folders inherit parent permissions

wes davidson at ling.ohio-state.edu
Sun Jan 20 02:02:40 UTC 2013


hi john.

as far as inheriting *ownership* goes, i think i might have an answer
for you below.

but as for inheriting certain permissions granted by that ownership, i am
not familiar with how that works.

On Sat, 19 Jan 2013, John Hupp wrote:
> I have two users(user1 and user2), but for a special purpose I want to 
> maintain a single store of files in the user1 home directory.
>
> So I added user1 and user2 to the "users" group, and reassigned the Group 
> property for /home/user1from "user1" to "users."
>
> I think that change automatically propagated to all the user1 
> sub-directories, but I can't remember for sure. It's possible that I manually 
> changed the sub-directory permissions, perhaps even before the change to 
> /home/user1.
>
> In any case, I thought that permission setup would automatically propagate to 
> any new sub-folders, but I just created user1/Documents/Documentation, and it 
> has Group: "user1."
>
> Can I configure this for the behavior I'm looking for?

to change the group ownership of a directory and all its *current*
subdirectories, the command chgrp with option -R might be what you're
looking for.

as for making it so that *newly created* subdirectories inherit that
group ownership, in addition to what you've done, i think that you
want to set the set-group-id bit for /home/user1.  try this:

   you at yourmachine:~$ chmod g+s /home/user1

the excerpt appended below, from the info pages installed on my ubuntu
10.04 system, suggests that might work.

cheers,
wes


27.4 Directories and the Set-User-ID and Set-Group-ID Bits
==========================================================

On most systems, if a directory's set-group-ID bit is set, newly
created subfiles inherit the same group as the directory, and newly
created subdirectories inherit the set-group-ID bit of the parent
directory.  On a few systems, a directory's set-user-ID bit has a
similar effect on the ownership of new subfiles and the set-user-ID
bits of new subdirectories.  These mechanisms let users share files
more easily, by lessening the need to use `chmod' or `chown' to share
new files.

    These convenience mechanisms rely on the set-user-ID and set-group-ID
bits of directories.  If commands like `chmod' and `mkdir' routinely
cleared these bits on directories, the mechanisms would be less
convenient and it would be harder to share files.  Therefore, a command
like `chmod' does not affect the set-user-ID or set-group-ID bits of a
directory unless the user specifically mentions them in a symbolic
mode, or sets them in a numeric mode.  For example, on systems that
support set-group-ID inheritance:

      # These commands leave the set-user-ID and
      # set-group-ID bits of the subdirectories alone,
      # so that they retain their default values.
      mkdir A B C
      chmod 755 A
      chmod 0755 B
      chmod u=rwx,go=rx C
      mkdir -m 755 D
      mkdir -m 0755 E
      mkdir -m u=rwx,go=rx F

    If you want to try to set these bits, you must mention them
explicitly in the symbolic or numeric modes, e.g.:

      # These commands try to set the set-user-ID
      # and set-group-ID bits of the subdirectories.
      mkdir G H
      chmod 6755 G
      chmod u=rwx,go=rx,a+s H
      mkdir -m 6755 I
      mkdir -m u=rwx,go=rx,a+s J

    If you want to try to clear these bits, you must mention them
explicitly in a symbolic mode, e.g.:

      # This command tries to clear the set-user-ID
      # and set-group-ID bits of the directory D.
      chmod a-s D

    This behavior is a GNU extension.  Portable scripts should not rely
on requests to set or clear these bits on directories, as POSIX allows
implementations to ignore these requests.






More information about the Lubuntu-users mailing list