Your specific situation
In your specific situation, we can guess that your current umask
is 002
(this is a common default value) and this explains your surprise.
In that specific situation where umask
value is 002 (all numbers octal).
+r
means ugo+r
because 002 & 444
is 000
, which lets all bits to be set
+x
means ugo+x
because 002 & 111
is 000
, which lets all bits to be set
- but
+w
means ug+w
because 002 & 222
is 002
, which prevents the "o" bit to be set.
Other examples
- With
umask 022
+w
would mean u+w
.
- With
umask 007
+rwx
would mean ug+rwx
.
- With
umask 077
+rwx
would mean u+rwx
.
What would have matched your expectations
When you change umask
to 000
, by executing
umask 000
in your terminal, then
chmod +w file
will set permissions to ugo+w.
Side note
As suggested by ilkkachu, note that umask 000
doesn't mean that everybody can read and write all your files.
But umask 000
means everyone that has some kind of access to any user account on your machine (which may include programs running server services ofc) can read and write all the files you make with that mask active and don't change (if the containing chain of directories up to the root also allows them).
ugo
, usea
.+w
not working.askubuntu
answer that you reference above that "This behavior is POSIX-mandated, and so, not a bug". Please be advised that POSIX Application Usage text is non-normative and is therefore not mandated by POSIX.