FreeBSD Manual Pages
umask(1) General Commands Manual umask(1) NAME umask - get or set the file mode creation mask SYNOPSIS /usr/bin/umask [ -S ] [ mask ] sh umask [ ooo ] csh umask [ ooo ] ksh umask [ -S ] [ mask ] AVAILABILITY SUNWcsu DESCRIPTION /usr/bin/umask The umask utility sets the file mode creation mask of the current shell execution environment to the value specified by the mask operand. This mask affects the initial value of the file permission bits of subse- quently created files. If umask is called in a subshell or separate utility execution environment, such as one of the following: (umask 002) nohup umask ... find . -exec umask ... it does not affect the file mode creation mask of the caller's environ- ment. If the mask operand is not specified, the umask utility writes the value of the invoking process's file mode creation mask to standard output. sh The user file-creation mode mask is set to ooo. The three octal digits refer to read/write/execute permissions for owner, group, and other, respectively (see chmod(1), chmod(2), and umask(2)). The value of each specified digit is subtracted from the corresponding ``digit'' speci- fied by the system for the creation of a file (see creat(2)). For ex- ample, umask 022 removes write permission for group and other (files normally created with mode 777 become mode 755; files created with mode 666 become mode 644). If ooo is omitted, the current value of the mask is printed. umask is recognized and executed by the shell. umask can be included in the user's .profile (see profile(4) ) and invoked at login to automatically set the user's permissions on files or directories created. csh See the description above for the Bourne shell (sh) umask built-in. ksh The user file-creation mask is set to mask. mask can either be an oc- tal number or a symbolic value as described in chmod(1). If a symbolic value is given, the new umask value is the complement of the result of applying mask to the complement of the previous umask value. If mask is omitted, the current value of the mask is printed. OPTIONS The following option is supported: -S Produce symbolic output. The default output style is unspecified, but will be recognised on a subsequent invocation of umask on the same system as a mask operand to restore the previous file mode creation mask. OPERANDS The following operand is supported: mask A string specifying the new file mode creation mask. The string is treated in the same way as the mode operand described in the chmod(1) manual page. For a symbolic_mode value, the new value of the file mode cre- ation mask is the logical complement of the file permission bits portion of the file mode specified by the symbolic_mode string. In a symbolic_mode value, the permissions op characters + and - are interpreted relative to the current file mode creation mask; + causes the of for the indicated permissions to be cleared in the mask; - causes the bits of the indicated permis- sions to be set in the mask. The interpretation of mode values that specify file mode bits other than the file permission bits is unspecified. The file mode creation mask is set to the resulting numeric value. The default output of a prior invocation of umask on the same system with no operand will also be recognized as a mask oper- and. The use of an operand obtained in this way is not obso- lescent, even if it is an octal number. OUTPUT When the mask operand is not specified, the umask utility will write a message to standard output that can later be used as a umask mask oper- and. If -S is specified, the message will be in the following format: "u=%s,g=%s,o=%s\n", <owner permissions>, <group permissions>, <other permissions> where the three values will be combinations of letters from the set {r, w, x}; the presence of a letter will indicate that the corresponding bit is clear in the file mode creation mask. If a mask operand is specified, there will be no output written to standard output. EXAMPLES Either of the commands: umask a=rx,ug+w umask 002 sets the mode mask so that subsequently created files have their S_IWOTH bit cleared. After setting the mode mask with either of the above commands, the umask command can be used to write the current value of the mode mask: $ umask 0002 (The output format is unspecified, but historical implementations use the obsolescent octal integer mode format.) $ umask -S 1 u=rwx,g=rwx,o=rx Either of these outputs can be used as the mask operand to a subsequent invocation of the umask utility. Assuming the mode mask is set as above, the command: umask g-w sets the mode mask so that subsequently created files have their S_IW- GRP, and S_IWOTH bits cleared. The command: umask -- -w sets the mode mask so that subsequently created files have all their write bits cleared. Note that mask operands r , w , x or anything be- ginning with a hyphen, must be preceded by -- to keep it from being in- terpreted as an option. ENVIRONMENT See environ(5) for descriptions of the following environment variables that affect the execution of umask: LC_CTYPE, LC_MESSAGES, and NLSPATH. EXIT STATUS The following exit values are returned: 0 The file mode creation mask was successfully changed, or no mask operand was supplied. >0 An error occurred. SEE ALSO chmod(1), csh(1), ksh(1), sh(1), chmod(2), creat(2), profile(4), envi- ron(5) 28 Mar 1995 umask(1)
NAME | SYNOPSIS | AVAILABILITY | DESCRIPTION | OPTIONS | OPERANDS | OUTPUT | EXAMPLES | ENVIRONMENT | EXIT STATUS | SEE ALSO
Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=umask&sektion=1&manpath=SunOS+5.5.1>