2

Here's a sequence of commands and the resulting output:

$ touch testfile
$ stat -c'%a %A' testfile
644 -rw-r--r--

What must I do so that when a user follows that sequence, I get this output instead:

664 -rw-rw-r--
2

POSIX defines the utility umask which sets the file mode creation mask, either for the current instance (without subshells), or for every newly invoked shell (over .bash_profile, .bashrc, etc.).

Show the currently set mask in octal or symbolic form:

$ umask
0022
$ umask -S
u=rwx,g=rwx,o=rx

The octal numbers indicate the values which are getting removed from the full access:

$ umask 0002     # or: umask g+w
$ touch testfile
$ stat -c'%a %A' testfile
664 -rw-rw-r--
1

You need to set the umask for that user to 0002. Right now, it's probably 0022. You can define it in your ~/.bash_profile with 'umask 0002'.

0

Under bash, umask sets the file-creation mask. With umask 002 you get the permissions you want. You can put this in .bash_profile locally or globally.

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.