Thursday, May 16, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 520  / 2 Years ago, thu, october 6, 2022, 4:53:59

In Linux when I create a directory mkdir newdir then the newly created directory has these permissions and ownership: drwxr-xr-x 2 owner group


My Question


How can I make the default permissions for newly created DIRECTORIES be: drwxrwxrwx 2 owner group regardless of who created the directory?


Some research I made


I know that from within a Samba share you can enforce that with directory mask but what if someone goes to the terminal and makes a directory as root and then a regular user comes along and he then won't be able to create files in that directory that the root user made?


I have been playing with ACLs and I understand how to make all newly created FILES have certain permissions.


e.g: setfacl -dRm u::rwX,g::rwX,o::0 newdir/


This makes all files in the newdir folder have permission: -rw-rw---- regardless of who created the file.


I also learnt about "setting the directory group id bit" so that any files (or directories) created in the "newdir" directory will have group ownership equal to the group ownership of the "newdir" directory.
chmod g+s newdir/


I have not been able to find out how to make the default permissions for a newly created DIRECTORY be: drwxrwxrwx 2 owner group regardless of who ever created the directory? Maybe it's something to do with umask? Can it be done with ACLs?


More From » command-line

 Answers
4

Yes you are correct - the default permissions are determined by the umask of the creating process. Unfortunately (unlike the SAMBA mount options, which provide separate dmask and fmask), the shell's umask applies to both directories and files:


$ umask 0000
$ mkdir newdir ; touch newfile
$ ls -ld new{dir,file}
drwxrwxrwx 1 steeldriver steeldriver 512 Mar 2 17:22 newdir
-rw-rw-rw- 1 steeldriver steeldriver 0 Mar 2 17:22 newfile

In any case, you can't control the umask of other user's processes (especially not root's).


[#1862] Thursday, October 6, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
vigorousom

Total Points: 394
Total Questions: 96
Total Answers: 110

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
vigorousom questions
Sun, May 15, 22, 08:14, 2 Years ago
Thu, Apr 6, 23, 22:39, 1 Year ago
Thu, Aug 25, 22, 07:55, 2 Years ago
;