If I want a directory and file to have the permissions:
-rw-r---w- -file
drwxr-x-w- - directory
why doesn't my umask value of 024 work?
If I want a directory and file to have the permissions:
-rw-r---w- -file
drwxr-x-w- - directory
why doesn't my umask value of 024 work?
Files are typically created with permissions rw-rw-rw-
(before the umask is applied), directories with permissions rwxrwxrwx
. Since you want rw-r---w-
and rwxr-x-w-
respectively, you need to mask ----w-r-x
.
You can set this using
umask 025
(set the mask as an octal value), or
umask u=rwx,g=rx,o=w
(set the allowed permissions in symbolic mode).
See Why doesn't umask change execute permissions on files? for a discussion of default permissions.
The default mask is u=rwx,g=rwx,o=rwx (octal 000)
umask u=rwx,g=rx,o=rx symbolic mode
umask 022 numeric mode
A numeric mask replaces the current file mode creation mask. It is specified as an unsigned octal integer, constructed from the logical OR (sum) of the following mode bits (leading zeros can be omitted):
0400 ( a=rwx,u-r) Read by owner
0200 ( a=rwx,u-w) Write by owner
0100 ( a=rwx,u-x) Execute (search in directory) by owner
0040 ( a=rwx,g-r) Read by group
0020 ( a=rwx,g-w) Write by group
0010 ( a=rwx,g-x) Execute/search by group
0004 ( a=rwx,o-r) Read by others
0002 ( a=rwx,o-w) Write by others
0001 ( a=rwx,o-x) Execute/search by others
To check umask value :
$ umask -S
u=rwx,g=rx,o=rx
drwxr-x-w-
)? – Stéphane Chazelas Jul 31 '22 at 17:05