Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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--
share|improve this question

3 Answers 3

up vote 2 down vote accepted

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--
share|improve this answer

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'.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.