This question is regarding samba file access.

I have created a folder A, and under folder A created two folders B and C. And also created three users A, B and C.

User A has access to all three folders but User B has only access to folder B and User C has only access to folder C.

Permission of B & C folders are:

drwxrwxr-x 3 a b 4096 May 10 16:22 b
drwxrwxr-x 3 a c 4096 May 10 16:43 c


When user B creates any new file under folder B, it's permission becomes

drwxr-x--- 2 b b 4096 May 10 16:21 New Folder

whereas I want it to keep the owner, group and permission same as folder B for any newly created files.

  • So you want a to own the file that b created?
    – Kevin
    May 10, 2013 at 18:22
  • "User A has access to all three folders" shall mean "write access"? Why do you want to change the owner, or is this about access rights only? May 10, 2013 at 18:53
  • a has write access to all three folders but b has only access to folder b. but when user A creates any file under folder B, user b not getting access to that folder or file
    – PeeJay
    May 10, 2013 at 18:58
  • ohh i am sorry i missed a main part. folder B and folder C is created under folder A.
    – PeeJay
    May 10, 2013 at 19:00
  • @Kevin main question was wrong...I have edited it now.
    – PeeJay
    May 10, 2013 at 19:03

1 Answer 1


Folder b and c are owned by user b and c. A file created by a user will belong to that user.

You can use the user permission for b and c, and the group permissions for a. If you set the SGID bit (g+s) on a folder, created files will get the group permission of that folder.

mkdir a
chown a:a a
chmod g+s a

mkdir b
chown b:a b

mkdir c
chown c:a c

(assuming all users are in a group of the same name.)

  • so i don't need to do sticky bit in folder b and c?
    – PeeJay
    May 10, 2013 at 19:16
  • they should get the bit automatically when being created inside a folder with that bit.
    – michas
    May 10, 2013 at 19:20
  • 1
    @user1723636, just so you understand the SGID bit and the "sticky bit" are 2 completely different things. See man chmod.
    – slm
    May 11, 2013 at 10:56
  • Also note that this solution is somewhat fragile, if users are able to move files into these directories, the SGID bit ownership will not get applied, so over time "strange" access problems will show up with specific files.
    – slm
    May 11, 2013 at 10:58
  • @slm - What should we do in order to make it less fragile?
    – Aust
    Mar 12, 2015 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.