I have a brand-new file called ./foo
, which looks like this:
#!/usr/bin/env bash
echo 'Hello world'
The output of the umask
command looks like so:
$ umask -S
u=rwx,g=rx,o=rx
$ umask
022
Yet, when I try to execute the brand-new file (no chmod
yet), I get the following:
$ ./foo
zsh: permission denied: ./foo
For what it's worth, I get the same thing when I open a bash
shell:
$ bash
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
bash-3.2$ ./foo
bash: ./foo: Permission denied
And when I inspect the file's permissions with ls -l
, it also appears to not be executable:
$ ls -l foo
-rw-r--r-- 1 richiethomas staff 40 Mar 3 10:11 foo
When I chmod
the file, however, it works as expected:
$ chmod +x foo
$ ./foo
Hello world
$ ls -l foo
-rwxr-xr-x 1 richiethomas staff 40 Mar 3 10:11 foo
Using this document as a source, I learned that a umask
value of 022
means "Owner has all permissions. Everyone else can read and execute, but not write."
If umask
is telling me that a file's creator (i.e. me) should be able to execute the file by default, why am I not in fact able to do so?