On my Pi, chmod +w doesn't behave as usual?

0

$ ls -al file1
-r--r--r-- 1 pi pi 0 Feb 10 15:18 file1

$ chmod +w file1
$ ls -al file1
-rw-r--r-- 1 pi pi 0 Feb 10 15:18 file1  #only u is updated

$ chmod +x file1
$ ls -al file1
-rwxr-xr-x 1 pi pi 0 Feb 10 15:18 file1  #all updated

Is this how chmod +w works?

Old Geezer

Posted 2016-02-10T12:30:13.037

Reputation: 613

Answers

1

Depends on what your umask is. If your umask is 022, then the +w gets masked in the group and other permissions flags. +x is not masked. To mask any of the executable flags, add 1 to the umask in that position. eg do umask 033 and try your test again.

ChrisDR

Posted 2016-02-10T12:30:13.037

Reputation: 136

1

From the man page:

If no value is supplied for who, each permission bit spec-
ified in perm, for which the corresponding bit in the file mode
creation mask (see umask(2)) is clear, is set.  Otherwise, the mode
bits represented by the specified who and perm values are set.

So if you don't specify who you want to update the permissions on it falls back to what the umask says to do with the permission you're setting. In this case your umask probably allows read and execute on files, so the execute bit gets set for everyone, but the umask probably only allows writing for the owner.

Eric Renouf

Posted 2016-02-10T12:30:13.037

Reputation: 1 548

1

This is defined by umask. It sets the default for creating and change of permissions of files.

To see the umask by default in a easy way issue the command umask -S . For example the result:

u=rwx,g=rx,o=rx
means that for user applies all, for group only read and execute, and the same for others.

To change it issue umask on this way:

umask x@y

where:

x could be: u (user), g(group),o (other) or a (all)

@ could be + to add permissions, - to remove permissions

y could be r (read), w(write), x(execute)

For example: umask g+w enable write permissions by default to group when you do a chmod +w.

More information here or issuing man umaskon the command prompt.

jcbermu

Posted 2016-02-10T12:30:13.037

Reputation: 15 868

1

The umask (by default 0022) is the reason the chmod +w change only the user attribute

$ chmod -v 444 a
mode of ‘a’ retained as 0444 (r--r--r--)
$ umask 000
$ chmod  -v +w a
mode of ‘a’ changed from 0444 (r--r--r--) to 0666 (rw-rw-rw-)
$ chmod -v +x a
mode of ‘a’ changed from 0666 (rw-rw-rw-) to 0777 (rwxrwxrwx)

François

Posted 2016-02-10T12:30:13.037

Reputation: 44