It seems that whenever I create a file with
touch the permissions are set to: -rw-r--r--.
Is there some way that I can configure the permissions with
touch or does this have to be done after with a different command?
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
You can modify your
umask to allow (for most implementations) more read/write privileges, but not executable, since generally the requested permissions are
022, you'll see
touch make a
Interestingly, POSIX describes this behavior in terms of
If file does not exist:
The creat() function is called with the following arguments:
The file operand is used as the path argument.
The value of the bitwise-inclusive OR of
S_IWOTHis used as the mode argument.
and it is only by following the links to
creat, then to
open, noticing the mention of
umask and back-tracking to
creat) to verify that
umask is supposed to affect
umask to affect only the
touch command, use a subshell:
(umask 066; touch private-file) (umask 0; touch world-writable-file) touch file-as-per-current-umask
(note that in any case, if the file existed beforehand,
touch will not change its permissions, just update its timestamps).
You can manipulate the
umask. Generally it's set to
022 which means when a user creates a file, it will get permission of
0644, you can manipulate
umask according to your needs.