2

I want to set the default permissions for newly created directories to have r-x for others and those of newly created files (non-directory files) to have ---.

If I set the umask to 2, directory permissions get r-x but files' get r--.

I couldn't find any way to achieve what I want with umask.

Ultimately, I want others to be able to traverse the directories but not to read the content of the files. I think that is a very reasonable demand but eventually there seems to be no such setting.

1 Answers1

5

If you only create directories with the mkdir command at the shell prompt, you could have:

umask 7
mkdir() (umask 2 && command mkdir "$@")

In your shell customisation file (~/.zshrc for zsh, ~/.bashrc for bash...).

That is set the umask to 7, but redefine mkdir to a function where the real mkdir is called (with the same arguments ("$@")) with a umask of 2. (note that the (...) create a subshell, so the umask 2 is only applied within that function).