Blame man-pages-posix-2013-a/man1p/umask.1p

Packit 7cfc04
'\" et
Packit 7cfc04
.TH UMASK "1P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
Packit 7cfc04
.SH PROLOG
Packit 7cfc04
This manual page is part of the POSIX Programmer's Manual.
Packit 7cfc04
The Linux implementation of this interface may differ (consult
Packit 7cfc04
the corresponding Linux manual page for details of Linux behavior),
Packit 7cfc04
or the interface may not be implemented on Linux.
Packit 7cfc04
Packit 7cfc04
.SH NAME
Packit 7cfc04
umask
Packit 7cfc04
\(em get or set the file mode creation mask
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.LP
Packit 7cfc04
.nf
Packit 7cfc04
umask \fB[\fR\(miS\fB] [\fImask\fB]\fR
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The
Packit 7cfc04
.IR umask
Packit 7cfc04
utility shall set the file mode creation mask of the current shell
Packit 7cfc04
execution environment (see
Packit 7cfc04
.IR "Section 2.12" ", " "Shell Execution Environment")
Packit 7cfc04
to the value specified by the
Packit 7cfc04
.IR mask
Packit 7cfc04
operand. This mask shall affect the initial value of the file
Packit 7cfc04
permission bits of subsequently created files. If
Packit 7cfc04
.IR umask
Packit 7cfc04
is called in a subshell or separate utility execution environment, such
Packit 7cfc04
as one of the following:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
(umask 002)
Packit 7cfc04
nohup umask ...
Packit 7cfc04
find . \(miexec umask ... \e;
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
it shall not affect the file mode creation mask of the caller's
Packit 7cfc04
environment.
Packit 7cfc04
.P
Packit 7cfc04
If the
Packit 7cfc04
.IR mask
Packit 7cfc04
operand is not specified, the
Packit 7cfc04
.IR umask
Packit 7cfc04
utility shall write to standard output the value of the
Packit 7cfc04
file mode creation mask of the invoking process.
Packit 7cfc04
.SH OPTIONS
Packit 7cfc04
The
Packit 7cfc04
.IR umask
Packit 7cfc04
utility shall conform to the Base Definitions volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "Section 12.2" ", " "Utility Syntax Guidelines".
Packit 7cfc04
.P
Packit 7cfc04
The following option shall be supported:
Packit 7cfc04
.IP "\fB\(miS\fP" 10
Packit 7cfc04
Produce symbolic output.
Packit 7cfc04
.P
Packit 7cfc04
The default output style is unspecified, but shall be recognized on a
Packit 7cfc04
subsequent invocation of
Packit 7cfc04
.IR umask
Packit 7cfc04
on the same system as a
Packit 7cfc04
.IR mask
Packit 7cfc04
operand to restore the previous file mode creation mask.
Packit 7cfc04
.SH OPERANDS
Packit 7cfc04
The following operand shall be supported:
Packit 7cfc04
.IP "\fImask\fR" 10
Packit 7cfc04
A string specifying the new file mode creation mask. The string is
Packit 7cfc04
treated in the same way as the
Packit 7cfc04
.IR mode
Packit 7cfc04
operand described in the EXTENDED DESCRIPTION section for
Packit 7cfc04
.IR chmod .
Packit 7cfc04
.RS 10 
Packit 7cfc04
.P
Packit 7cfc04
For a
Packit 7cfc04
.IR symbolic_mode
Packit 7cfc04
value, the new value of the file mode creation mask shall be the
Packit 7cfc04
logical complement of the file permission bits portion of the file mode
Packit 7cfc04
specified by the
Packit 7cfc04
.IR symbolic_mode
Packit 7cfc04
string.
Packit 7cfc04
.P
Packit 7cfc04
In a
Packit 7cfc04
.IR symbolic_mode
Packit 7cfc04
value, the permissions
Packit 7cfc04
.IR op
Packit 7cfc04
characters
Packit 7cfc04
.BR '\(pl' 
Packit 7cfc04
and
Packit 7cfc04
.BR '\(mi' 
Packit 7cfc04
shall be interpreted relative to the current file mode creation mask;
Packit 7cfc04
.BR '\(pl' 
Packit 7cfc04
shall cause the bits for the indicated permissions to be cleared in the
Packit 7cfc04
mask;
Packit 7cfc04
.BR '\(mi' 
Packit 7cfc04
shall cause the bits for the indicated permissions to be set in the
Packit 7cfc04
mask.
Packit 7cfc04
.P
Packit 7cfc04
The interpretation of
Packit 7cfc04
.IR mode
Packit 7cfc04
values that specify file mode bits other than the file permission bits
Packit 7cfc04
is unspecified.
Packit 7cfc04
.P
Packit 7cfc04
In the octal integer form of
Packit 7cfc04
.IR mode ,
Packit 7cfc04
the specified bits are set in the file mode creation mask.
Packit 7cfc04
.P
Packit 7cfc04
The file mode creation mask shall be set to the resulting numeric
Packit 7cfc04
value.
Packit 7cfc04
.P
Packit 7cfc04
The default output of a prior invocation of
Packit 7cfc04
.IR umask
Packit 7cfc04
on the same system with no operand also shall be recognized as a
Packit 7cfc04
.IR mask
Packit 7cfc04
operand.
Packit 7cfc04
.RE
Packit 7cfc04
.SH STDIN
Packit 7cfc04
Not used.
Packit 7cfc04
.SH "INPUT FILES"
Packit 7cfc04
None.
Packit 7cfc04
.SH "ENVIRONMENT VARIABLES"
Packit 7cfc04
The following environment variables shall affect the execution of
Packit 7cfc04
.IR umask :
Packit 7cfc04
.IP "\fILANG\fP" 10
Packit 7cfc04
Provide a default value for the internationalization variables that are
Packit 7cfc04
unset or null. (See the Base Definitions volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "Section 8.2" ", " "Internationalization Variables"
Packit 7cfc04
for the precedence of internationalization variables used to determine
Packit 7cfc04
the values of locale categories.)
Packit 7cfc04
.IP "\fILC_ALL\fP" 10
Packit 7cfc04
If set to a non-empty string value, override the values of all the
Packit 7cfc04
other internationalization variables.
Packit 7cfc04
.IP "\fILC_CTYPE\fP" 10
Packit 7cfc04
Determine the locale for the interpretation of sequences of bytes of
Packit 7cfc04
text data as characters (for example, single-byte as opposed to
Packit 7cfc04
multi-byte characters in arguments).
Packit 7cfc04
.IP "\fILC_MESSAGES\fP" 10
Packit 7cfc04
.br
Packit 7cfc04
Determine the locale that should be used to affect the format and
Packit 7cfc04
contents of diagnostic messages written to standard error.
Packit 7cfc04
.IP "\fINLSPATH\fP" 10
Packit 7cfc04
Determine the location of message catalogs for the processing of
Packit 7cfc04
.IR LC_MESSAGES .
Packit 7cfc04
.SH "ASYNCHRONOUS EVENTS"
Packit 7cfc04
Default.
Packit 7cfc04
.SH STDOUT
Packit 7cfc04
When the
Packit 7cfc04
.IR mask
Packit 7cfc04
operand is not specified, the
Packit 7cfc04
.IR umask
Packit 7cfc04
utility shall write a message to standard output that can later be used
Packit 7cfc04
as a
Packit 7cfc04
.IR umask
Packit 7cfc04
.IR mask
Packit 7cfc04
operand.
Packit 7cfc04
.P
Packit 7cfc04
If
Packit 7cfc04
.BR \(miS
Packit 7cfc04
is specified, the message shall be in the following format:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
"u=%s,g=%s,o=%s\en", <\fIowner permissions\fR>, <\fIgroup permissions\fR>,
Packit 7cfc04
    <\fIother permissions\fR>
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
where the three values shall be combinations of letters from the set
Packit 7cfc04
{\c
Packit 7cfc04
.IR r ,
Packit 7cfc04
.IR w ,
Packit 7cfc04
.IR x };
Packit 7cfc04
the presence of a letter shall indicate that the corresponding bit is
Packit 7cfc04
clear in the file mode creation mask.
Packit 7cfc04
.P
Packit 7cfc04
If a
Packit 7cfc04
.IR mask
Packit 7cfc04
operand is specified, there shall be no output written to standard
Packit 7cfc04
output.
Packit 7cfc04
.SH STDERR
Packit 7cfc04
The standard error shall be used only for diagnostic messages.
Packit 7cfc04
.SH "OUTPUT FILES"
Packit 7cfc04
None.
Packit 7cfc04
.SH "EXTENDED DESCRIPTION"
Packit 7cfc04
None.
Packit 7cfc04
.SH "EXIT STATUS"
Packit 7cfc04
The following exit values shall be returned:
Packit 7cfc04
.IP "\00" 6
Packit 7cfc04
The file mode creation mask was successfully changed, or no
Packit 7cfc04
.IR mask
Packit 7cfc04
operand was supplied.
Packit 7cfc04
.IP >0 6
Packit 7cfc04
An error occurred.
Packit 7cfc04
.SH "CONSEQUENCES OF ERRORS"
Packit 7cfc04
Default.
Packit 7cfc04
.LP
Packit 7cfc04
.IR "The following sections are informative."
Packit 7cfc04
.SH "APPLICATION USAGE"
Packit 7cfc04
Since
Packit 7cfc04
.IR umask
Packit 7cfc04
affects the current shell execution environment, it is generally
Packit 7cfc04
provided as a shell regular built-in.
Packit 7cfc04
.P
Packit 7cfc04
In contrast to the negative permission logic provided by the file mode
Packit 7cfc04
creation mask and the octal number form of the
Packit 7cfc04
.IR mask
Packit 7cfc04
argument, the symbolic form of the
Packit 7cfc04
.IR mask
Packit 7cfc04
argument specifies those permissions that are left alone.
Packit 7cfc04
.SH EXAMPLES
Packit 7cfc04
Either of the commands:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
umask a=rx,ug+w
Packit 7cfc04
.P
Packit 7cfc04
umask 002
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
sets the mode mask so that subsequently created files have their
Packit 7cfc04
S_IWOTH bit cleared.
Packit 7cfc04
.P
Packit 7cfc04
After setting the mode mask with either of the above commands, the
Packit 7cfc04
.IR umask
Packit 7cfc04
command can be used to write out the current value of the mode mask:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
\fB$ \fRumask
Packit 7cfc04
\fB0002\fR
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
(The output format is unspecified, but historical implementations use
Packit 7cfc04
the octal integer mode format.)
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
\fB$ \fRumask \(miS
Packit 7cfc04
\fBu=rwx,g=rwx,o=rx\fR
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
Either of these outputs can be used as the mask operand to a subsequent
Packit 7cfc04
invocation of the
Packit 7cfc04
.IR umask
Packit 7cfc04
utility.
Packit 7cfc04
.P
Packit 7cfc04
Assuming the mode mask is set as above, the command:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
umask g\(miw
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
sets the mode mask so that subsequently created files have their
Packit 7cfc04
S_IWGRP and S_IWOTH bits cleared.
Packit 7cfc04
.P
Packit 7cfc04
The command:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
umask \(mi\|\(mi \(miw
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
sets the mode mask so that subsequently created files have all their
Packit 7cfc04
write bits cleared. Note that
Packit 7cfc04
.IR mask
Packit 7cfc04
operands
Packit 7cfc04
.BR \(mir ,
Packit 7cfc04
.BR \(miw ,
Packit 7cfc04
.BR \(mix
Packit 7cfc04
or anything beginning with a
Packit 7cfc04
<hyphen>,
Packit 7cfc04
must be preceded by
Packit 7cfc04
.BR \(dq\(mi\|\(mi\(dq 
Packit 7cfc04
to keep it from being interpreted as an option.
Packit 7cfc04
.SH RATIONALE
Packit 7cfc04
Since
Packit 7cfc04
.IR umask
Packit 7cfc04
affects the current shell execution environment,
Packit 7cfc04
it is generally provided as a shell regular built-in. If it is called
Packit 7cfc04
in a subshell or separate utility execution environment, such as one of
Packit 7cfc04
the following:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
(umask 002)
Packit 7cfc04
nohup umask ...
Packit 7cfc04
find . \(miexec umask ... \e;
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
it does not affect the file mode creation mask of the environment of
Packit 7cfc04
the caller.
Packit 7cfc04
.P
Packit 7cfc04
The description of the historical utility was modified to allow it to
Packit 7cfc04
use the symbolic modes of
Packit 7cfc04
.IR chmod .
Packit 7cfc04
The
Packit 7cfc04
.BR \(mis
Packit 7cfc04
option used in early proposals was changed to
Packit 7cfc04
.BR \(miS
Packit 7cfc04
because
Packit 7cfc04
.BR \(mis
Packit 7cfc04
could be confused with a
Packit 7cfc04
.IR symbolic_mode
Packit 7cfc04
form of mask referring to the S_ISUID and S_ISGID bits.
Packit 7cfc04
.P
Packit 7cfc04
The default output style is unspecified to permit implementors to
Packit 7cfc04
provide migration to the new symbolic style at the time most
Packit 7cfc04
appropriate to their users. A
Packit 7cfc04
.BR \(mio
Packit 7cfc04
flag to force octal mode output was omitted because the octal mode may
Packit 7cfc04
not be sufficient to specify all of the information that may be present
Packit 7cfc04
in the file mode creation mask when more secure file access permission
Packit 7cfc04
checks are implemented.
Packit 7cfc04
.P
Packit 7cfc04
It has been suggested that trusted systems developers might appreciate
Packit 7cfc04
ameliorating the requirement that the mode mask ``affects'' the file
Packit 7cfc04
access permissions, since it seems access control lists might replace
Packit 7cfc04
the mode mask to some degree. The wording has been changed to say that
Packit 7cfc04
it affects the file permission bits, and it leaves the details of the
Packit 7cfc04
behavior of how they affect the file access permissions to the
Packit 7cfc04
description in the System Interfaces volume of POSIX.1\(hy2008.
Packit 7cfc04
.SH "FUTURE DIRECTIONS"
Packit 7cfc04
None.
Packit 7cfc04
.SH "SEE ALSO"
Packit 7cfc04
.IR "Chapter 2" ", " "Shell Command Language",
Packit 7cfc04
.IR "\fIchmod\fR\^"
Packit 7cfc04
.P
Packit 7cfc04
The Base Definitions volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "Chapter 8" ", " "Environment Variables",
Packit 7cfc04
.IR "Section 12.2" ", " "Utility Syntax Guidelines"
Packit 7cfc04
.P
Packit 7cfc04
The System Interfaces volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "\fIumask\fR\^(\|)"
Packit 7cfc04
.SH COPYRIGHT
Packit 7cfc04
Portions of this text are reprinted and reproduced in electronic form
Packit 7cfc04
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
Packit 7cfc04
-- Portable Operating System Interface (POSIX), The Open Group Base
Packit 7cfc04
Specifications Issue 7, Copyright (C) 2013 by the Institute of
Packit 7cfc04
Electrical and Electronics Engineers, Inc and The Open Group.
Packit 7cfc04
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
Packit 7cfc04
event of any discrepancy between this version and the original IEEE and
Packit 7cfc04
The Open Group Standard, the original IEEE and The Open Group Standard
Packit 7cfc04
is the referee document. The original Standard can be obtained online at
Packit 7cfc04
http://www.unix.org/online.html .
Packit 7cfc04
Packit 7cfc04
Any typographical or formatting errors that appear
Packit 7cfc04
in this page are most likely
Packit 7cfc04
to have been introduced during the conversion of the source files to
Packit 7cfc04
man page format. To report such errors, see
Packit 7cfc04
https://www.kernel.org/doc/man-pages/reporting_bugs.html .