linuxbashchmod

if chmod doesn't use umask for "chmod +" (no ugoa) commands, then why does this happen?


Im confused because searches told me that using chmod + (without specifying ugoa) does not use umask, but i did test in a debian console and got this (i notated in parenthesis):

root@minecraft-server:/opt# umask 0022
root@minecraft-server:/opt# ls -ld
drwxr-xr-x 4 minecraft minecraft 8 Jun 16 23:11 . (STARTING POINT)
root@minecraft-server:/opt# chmod +w .
root@minecraft-server:/opt# ls -ld
drwxr-xr-x 4 minecraft minecraft 8 Jun 16 23:11 . (NO CHANGES)
root@minecraft-server:/opt# umask 0000 (CHANGING UMASK)
root@minecraft-server:/opt# chmod +w .
root@minecraft-server:/opt# ls -ld
drwxrwxrwx 4 minecraft minecraft 8 Jun 16 23:11 . (NOW THERE ARE CHANGES)
root@minecraft-server:/opt# umask 0022
root@minecraft-server:/opt# chmod -w .
chmod: .: new permissions are r-xrwxrwx, not r-xr-xr-x (WARNING AFTER UMASK CHANGE DETECTION [I THINK])
root@minecraft-server:/opt# ls -ld
dr-xrwxrwx 4 minecraft minecraft 8 Jun 16 23:11 .
root@minecraft-server:/opt# chmod +w .
root@minecraft-server:/opt# chmod go-w .
root@minecraft-server:/opt# ls -ld
drwxr-xr-x 4 minecraft minecraft 8 Jun 16 23:11 . (BACK TO NORMAL)

Can someone please explain this?


Solution

  • Im confused because ai and google searches told me

    Time to start learning from the actual docs for the commands you use, then.

    Saying man chmod and then /umask got me to this paragraph right quick:

    A combination of the letters ugoa controls which users' access to the file will be changed: the user who owns it (u), other users in the file's group (g), other users not in the file's group (o), or all users (a). If none of these are given, the effect is as if (a) were given, but bits that are set in the umask are not affected.

    and notice that last sentence there, the one that hit on umask.