1

My umask is currently (default) set to 0002, as shown below. I understand that the permissions from right to left are, other, user, owner. So what is the first 0 for?

$ umask
0002
john smith
  • 3,033

1 Answers1

0

First the numbers are octal numbers.

Let me use an example to explain what they all mean.

Note that setuid and setgid (setuid - set user id, and setgid - set group id) are done using the numbers 4 and 2 where sudo chmod 4775 will change or set user id on the file or directory when sudo chmod setgid is done.

For files that is ownwd by root and group www-data, if you do say sudo chmod 6711 file here several things are happening:

  1. make file read/write/executable for owner(7)
  2. make file executable for group(1)
  3. make file 'executable` for others(1)
  4. Then when file is executed by any other than owner the file will run as root:www-data no matter who executes the file.

In summary if you do sudo chmod 6711 and another user runs that file, it will run as though you (the owner) executed the file.

For directories:

if you do sudo chmod g+s on a folder then all files created from hence forth will inherit the group of the original creator not you who just created it. Note: that any file already there will not inherit the new group you need to do that manually.

The same will happen if you do sudo chmod u+s

We have the sticky bit which is done like this: chmod 1000 directory or chmod +t directory.

When the sticky bit is set on a directory, files in that directory may only be unlinked or renamed by root or the directory owner or the file owner

For more information check here.

George Udosen
  • 36,677