umask | umask -S

 umask is a command that determines the settings of a mask that controls how file permissions are set for newly created files

The mask is stored as a group of bits. It may be represented as binaryoctal or symbolic notation. The umask command allows the mask to be set as octal (e.g. 0754) or symbolic (e.g. u=,g=w,o=wx) notation.

$ umask         # display current value (as octal)
0022
$ umask -S      # display current value symbolically
u=rwx,g=rx,o=rx

$ umask 007    # set the mask to 007
$ umask        # display the mask (in octal)
0007           #   0 - special permissions (setuid | setgid | sticky )
               #   0 - (u)ser/owner part of mask
               #   0 - (g)roup part of mask
               #   7 - (o)thers/not-in-group part of mask
$ umask -S     # display the mask symbolically
u=rwx,g=rwx,o=

LetterClassDescription
uuserthe owner
ggroupusers who are members of the file's group
oothersusers who are not the owner of the file or members of the group
aallall three of the above, the same as ugo. (The default if no user-class-letters are specified in the maskExpression.)
  • The operator specifies how the permission modes of the mask should be adjusted.
OperatorEffect on the mask
+permissions specified are enabled, permissions that are not specified are unchanged.
-permissions specified are prohibited from being enabled, permissions that are not specified are unchanged.
=permissions specified are enabled, permissions that are not specified are prohibited from being enabled.
  • The permission-symbols indicate which file permission settings are to be allowed or prohibited by the mask.
SymbolNameDescription
rreadread a file or list a directory's contents
wwritewrite to a file or directory
xexecuteexecute a file or recurse a directory tree
Xspecial executeSee Symbolic modes.
ssetuid/gidSee File permissions.
tstickySee File permissions.

Command line examples[edit]

Here are more examples of using the umask command to change the mask.
umask command issuedHow the mask will affect permissions of subsequently created files/directories
umask a+rallows read permission to be enabled for all user classes; the rest of the mask bits are unchanged
umask a-xprohibits enabling execute permission for all user classes; the rest of the mask bits are unchanged
umask a+rwallows read or write permission to be enabled for all user classes; the rest of the mask bits are unchanged
umask +rwxallows read, write or execute permission to be enabled for all user classes; (Note: On some UNIX platforms, this will restore the mask to a default.)
umask u=rw,go=allow read and write permission to be enabled for the owner, while prohibiting execute permission from being enabled for the owner; prohibit enabling any permissions for the group and others
umask u+w,go-wallow write permission to be enabled for the owner; prohibit write permission from being enabled for the group and others;
umask -Sdisplay the current umask in symbolic notation
umask 777disallow read, write, and execute permission for all (probably not useful because even owner cannot read files created with this mask!)
umask 000allow read, write, and execute permission for all (potential security risk)
umask 077allow read, write, and execute permission for the file's owner, but prohibit read, write, and execute permission for everyone else
umask 113allow read or write permission to be enabled for the owner and the group, but not execute permission; allow read permission to be enabled for others, but not write or execute permission
umask 0755equivalent to u-rwx (4+2+1),go=w (4+1 & 4+1). (The 0 specifies that special modes[clarify] may be enabled if allowed by the OS.)




Comments

Popular posts from this blog

HAproxy logging

tomcat catalina coyote jasper cluster

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all