-1

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?

2
  • How do you create a file and directory, command? Commented Jul 25, 2022 at 14:18
  • What's the point of giving write access to a directory without search access (for others in your drwxr-x-w-)? Commented Jul 31, 2022 at 17:05

2 Answers 2

1

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.

0
-1

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 
1
  • (1) This answer is little more than ‘‘RTFM’’, except you politely read the manual to the OP.  But it doesn’t really answer the question. (2) What do you mean by ‘‘A numeric mask replaces the current file mode creation mask.’’? Commented Jul 31, 2022 at 13:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.