Search code examples
file-permissionsredhatsamba

how to keep file owner same for newly created files


This question is regarding samba file access.

I have created three folder A, 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

Problem:

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.


Solution

  • Actually, if you want to change the default permission for making any file, you have to use UMASK command that can change the default permissions. I will give an example :

    umask 222 
    

    This command will make the default permission to r-x. Why? Because the default for umask is 777 when you type umask 222 that will subtract from 777 and will make to 555 Hopefully I gave you what you need.