When you run chmod +x+r+w file
, all the bits are set, except those masked by your umask
. Your umask
presumably masks (at least) other users’ write bit, so the +w
part ends up being ignored for them.
Thus for a typical umask
of 022, any chmod
command which doesn’t specify who the permissions should be set for ends up ignoring any specified changes to the group’s and others’ write bits.
To set all the bits, ignoring umask
, you need to specify who you want to set them for:
chmod a+rwx file
or more explicitly,
chmod ugo+rwx file
(or any subset of ugo
, as appropriate, for the user, group, and/or others).
It’s also possible to specify numeric permissions instead of symbolic permissions; see Understanding UNIX permissions and file types for details.
Note that the umask
masking behaviour also applies when clearing bits, which can produce surprising results: chmod -w file
will only clear write bits which would be set by chmod +w file
! Continuing with a typical umask
of 022, this means that chmod -w
won’t touch the group’s or others’ write bits, leaving them set if they already are. (GNU coreutils
’ chmod
helpfully warns about this.)
chmod
warns about that:chmod 777 test.txt; chmod -w test.txt
giveschmod: test.txt: new permissions are r-xrwxrwx, not r-xr-xr-x
– ilkkachu Oct 30 '21 at 17:20ls
returns the file listing) in addition to read/write the file itself. – Ian W Oct 31 '21 at 00:02x
), not to list its content (ie.r
). – Ginnungagap Oct 31 '21 at 07:50ls -l
(which wouldn’t work correctly if the OP couldn’t read and traverse the current directory). I prefer to keep answers focused on the problem at hand, rather than attempting to address all possible areas of misunderstanding. – Stephen Kitt Oct 31 '21 at 20:18ls -l
tells us nothing about what other users can see, since that was run by the owner. (You're right not to clutter the answer second-guessing that part, though - that's a totally different question!) – Toby Speight Nov 01 '21 at 13:47chmod
would even be possible, not as being about the permissions required so that others could write to the file! But even for that, if one assumes the read permission was already effective, then everything is already OK. – Stephen Kitt Nov 01 '21 at 15:13