Umask: Difference between revisions

From UMIACS
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
[[umask]] is the way the UNIX operating system determines what default permissions that files and directories are created with.
[[umask]] is the way the UNIX operating system determines what default permissions that files and directories are created with.


The mask itself is applied as a bitwise AND operation then a bitwise NOT of that with the default 777 permisions eg.,
The mask itself is applied as a bitwise AND operation then a bitwise NOT of that with the default 777 permisions.
 
        777
AND NOT 022
      = 755


The three popular [[umask]]s are 022, 002 and 000.
The three popular [[umask]]s are 022, 002 and 000.
Line 11: Line 7:
==022==
==022==
This as the example shows above that you will get full rwx for the user, r-x for the group and r-x for other.  This is the default in almost all of our operating systems.
This as the example shows above that you will get full rwx for the user, r-x for the group and r-x for other.  This is the default in almost all of our operating systems.
    user          group        other
  r  w    x        r    w    x      r    w    x
  111 111 111    111 111 111  111 111 111
        777
AND NOT 022
      = 755


==002==
==002==
This would give full rwx for the user, full rwx for the group and give only r-x for other.  This is helpful when you want your default group (or a [[SetGID]] directory) to have full control over the files and directories you create while allowing everyone else read and execute permissions.
This would give full rwx for the user, full rwx for the group and give only r-x for other.  This is helpful when you want your default group (or a [[SetGID]] directory) to have full control over the files and directories you create while allowing everyone else read and execute permissions.
        777
AND NOT 002
      = 775


==000==
==000==
This is the most restrictive [[umask]] and gives no permissions
This is the most restrictive [[umask]] and gives no permissions
        777
AND NOT 022
      = 770

Revision as of 17:40, 16 June 2008

umask is the way the UNIX operating system determines what default permissions that files and directories are created with.

The mask itself is applied as a bitwise AND operation then a bitwise NOT of that with the default 777 permisions.

The three popular umasks are 022, 002 and 000.

022

This as the example shows above that you will get full rwx for the user, r-x for the group and r-x for other. This is the default in almost all of our operating systems.

    user           group        other
  r   w    x        r     w    x      r    w    x
 111 111 111    111 111 111  111 111 111

        777
AND NOT 022
      = 755

002

This would give full rwx for the user, full rwx for the group and give only r-x for other. This is helpful when you want your default group (or a SetGID directory) to have full control over the files and directories you create while allowing everyone else read and execute permissions.

        777
AND NOT 002
      = 775

000

This is the most restrictive umask and gives no permissions

        777
AND NOT 022
      = 770