Quote:
Originally posted by Rodolfo Medina
I mean, is there a way to make the command `chmod'
act upon files in a certain directory that have not been created yet?
For example:
# mkdir mydir
# touch mydir/file1
# ls -l mydir
total 0
-rw-r--r-- 1 root root 0 ago 16 12:36 file1
# chmod go-r mydir/*
# ls -l mydir
total 0
-rw------- 1 root root 0 ago 16 12:36 file1
# touch mydir/file2
# ls -l mydir
total 0
-rw------- 1 root root 0 ago 16 12:36 file1
-rw-r--r-- 1 root root 0 ago 16 12:38 file2
. The new file created, file2, is not affected by the command '# chmod go-r mydir/*'
previously given. Was it possible, and how,
that file2 were born with same permissions of file1?
Thanks for any reply,
Rodolfo
|
UMASK affects the permissions that a file/directory gets when it is created.
If i understand correctly, this is what you mean.
the parameter it gets is the octal number that gets subtracted from 666 (rw-) or 777 (rwx for directories)
In your example you want rw for owner and nothing for others so you want permissions 600, so the umask is 077
usual examples of umask is 077 (which gives rw-------) and 022 (which givers rw-r--r--)
As you see you have 022 umask that is why the file2 gets those permissions.
I don't know what distribution you use, but usually every major distribution uses a default umask in /etc/profile for /bin/bash
For example my /etc/profile has the following:
# Default umask. A umask of 022 prevents new files from being created group
# and world writable.
umask 022