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:
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
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--
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'.
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.