UMASK(1)                   POSIX Programmer's Manual                  UMASK(1)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.

NNAAMMEE
       umask -- get or set the file mode creation mask

SSYYNNOOPPSSIISS
       umask [[-S]] [[_m_a_s_k]]

DDEESSCCRRIIPPTTIIOONN
       The _u_m_a_s_k utility shall set the file mode creation mask of the current
       shell execution environment (see _S_e_c_t_i_o_n _2_._1_2, _S_h_e_l_l _E_x_e_c_u_t_i_o_n
       _E_n_v_i_r_o_n_m_e_n_t) to the value specified by the _m_a_s_k operand. This mask
       shall affect the initial value of the file permission bits of
       subsequently created files. If _u_m_a_s_k is called in a subshell or
       separate utility execution environment, such as one of the following:


           (umask 002)
           nohup umask ...
           find . -exec umask ... \;

       it shall not affect the file mode creation mask of the caller's
       environment.

       If the _m_a_s_k operand is not specified, the _u_m_a_s_k utility shall write to
       standard output the value of the file mode creation mask of the
       invoking process.

OOPPTTIIOONNSS
       The _u_m_a_s_k utility shall conform to the Base Definitions volume of
       POSIX.1-2017, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s.

       The following option shall be supported:

       --SS        Produce symbolic output.

       The default output style is unspecified, but shall be recognized on a
       subsequent invocation of _u_m_a_s_k on the same system as a _m_a_s_k operand to
       restore the previous file mode creation mask.

OOPPEERRAANNDDSS
       The following operand shall be supported:

       _m_a_s_k      A string specifying the new file mode creation mask. The
                 string is treated in the same way as the _m_o_d_e operand
                 described in the EXTENDED DESCRIPTION section for _c_h_m_o_d.

                 For a _s_y_m_b_o_l_i_c___m_o_d_e value, the new value of the file mode
                 creation mask shall be the logical complement of the file
                 permission bits portion of the file mode specified by the
                 _s_y_m_b_o_l_i_c___m_o_d_e string.

                 In a _s_y_m_b_o_l_i_c___m_o_d_e value, the permissions _o_p characters ''++''
                 and ''--'' shall be interpreted relative to the current file
                 mode creation mask; ''++'' shall cause the bits for the
                 indicated permissions to be cleared in the mask; ''--'' shall
                 cause the bits for the indicated permissions to be set in the
                 mask.

                 The interpretation of _m_o_d_e values that specify file mode bits
                 other than the file permission bits is unspecified.

                 In the octal integer form of _m_o_d_e, the specified bits are set
                 in the file mode creation mask.

                 The file mode creation mask shall be set to the resulting
                 numeric value.

                 The default output of a prior invocation of _u_m_a_s_k on the same
                 system with no operand also shall be recognized as a _m_a_s_k
                 operand.

SSTTDDIINN
       Not used.

IINNPPUUTT FFIILLEESS
       None.

EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
       The following environment variables shall affect the execution of
       _u_m_a_s_k:

       _L_A_N_G      Provide a default value for the internationalization
                 variables that are unset or null. (See the Base Definitions
                 volume of POSIX.1-2017, _S_e_c_t_i_o_n _8_._2, _I_n_t_e_r_n_a_t_i_o_n_a_l_i_z_a_t_i_o_n
                 _V_a_r_i_a_b_l_e_s for the precedence of internationalization
                 variables used to determine the values of locale categories.)

       _L_C___A_L_L    If set to a non-empty string value, override the values of
                 all the other internationalization variables.

       _L_C___C_T_Y_P_E  Determine the locale for the interpretation of sequences of
                 bytes of text data as characters (for example, single-byte as
                 opposed to multi-byte characters in arguments).

       _L_C___M_E_S_S_A_G_E_S
                 Determine the locale that should be used to affect the format
                 and contents of diagnostic messages written to standard
                 error.

       _N_L_S_P_A_T_H   Determine the location of message catalogs for the processing
                 of _L_C___M_E_S_S_A_G_E_S.

AASSYYNNCCHHRROONNOOUUSS EEVVEENNTTSS
       Default.

SSTTDDOOUUTT
       When the _m_a_s_k operand is not specified, the _u_m_a_s_k utility shall write a
       message to standard output that can later be used as a _u_m_a_s_k _m_a_s_k
       operand.

       If --SS is specified, the message shall be in the following format:


           "u=%s,g=%s,o=%s\n", <_o_w_n_e_r _p_e_r_m_i_s_s_i_o_n_s>, <_g_r_o_u_p _p_e_r_m_i_s_s_i_o_n_s>,
               <_o_t_h_e_r _p_e_r_m_i_s_s_i_o_n_s>

       where the three values shall be combinations of letters from the set
       {_r, _w, _x}; the presence of a letter shall indicate that the
       corresponding bit is clear in the file mode creation mask.

       If a _m_a_s_k operand is specified, there shall be no output written to
       standard output.

SSTTDDEERRRR
       The standard error shall be used only for diagnostic messages.

OOUUTTPPUUTT FFIILLEESS
       None.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
       The following exit values shall be returned:

        0    The file mode creation mask was successfully changed, or no _m_a_s_k
             operand was supplied.

       >0    An error occurred.

CCOONNSSEEQQUUEENNCCEESS OOFF EERRRROORRSS
       Default.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       Since _u_m_a_s_k affects the current shell execution environment, it is
       generally provided as a shell regular built-in.

       In contrast to the negative permission logic provided by the file mode
       creation mask and the octal number form of the _m_a_s_k argument, the
       symbolic form of the _m_a_s_k argument specifies those permissions that are
       left alone.

EEXXAAMMPPLLEESS
       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
       _u_m_a_s_k command can be used to write out the current value of the mode
       mask:


           $$ umask
           00000022

       (The output format is unspecified, but historical implementations use
       the octal integer mode format.)


           $$ umask -S
           uu==rrwwxx,,gg==rrwwxx,,oo==rrxx

       Either of these outputs can be used as the mask operand to a subsequent
       invocation of the _u_m_a_s_k 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_IWGRP 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 _m_a_s_k operands --rr, --ww, --xx or anything
       beginning with a <hyphen-minus>, must be preceded by ""----"" to keep it
       from being interpreted as an option.

RRAATTIIOONNAALLEE
       Since _u_m_a_s_k affects the current shell execution environment, it is
       generally provided as a shell regular built-in. If it 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 environment of
       the caller.

       The description of the historical utility was modified to allow it to
       use the symbolic modes of _c_h_m_o_d.  The --ss option used in early proposals
       was changed to --SS because --ss could be confused with a _s_y_m_b_o_l_i_c___m_o_d_e
       form of mask referring to the S_ISUID and S_ISGID bits.

       The default output style is unspecified to permit implementors to
       provide migration to the new symbolic style at the time most
       appropriate to their users. A --oo flag to force octal mode output was
       omitted because the octal mode may not be sufficient to specify all of
       the information that may be present in the file mode creation mask when
       more secure file access permission checks are implemented.

       It has been suggested that trusted systems developers might appreciate
       ameliorating the requirement that the mode mask ``affects'' the file
       access permissions, since it seems access control lists might replace
       the mode mask to some degree. The wording has been changed to say that
       it affects the file permission bits, and it leaves the details of the
       behavior of how they affect the file access permissions to the
       description in the System Interfaces volume of POSIX.1-2017.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _C_h_a_p_t_e_r _2, _S_h_e_l_l _C_o_m_m_a_n_d _L_a_n_g_u_a_g_e, _c_h_m_o_d

       The Base Definitions volume of POSIX.1-2017, _C_h_a_p_t_e_r _8, _E_n_v_i_r_o_n_m_e_n_t
       _V_a_r_i_a_b_l_e_s, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s

       The System Interfaces volume of POSIX.1-2017, _u_m_a_s_k()

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  In the event of any discrepancy between this version and the
       original IEEE and The Open Group Standard, the original IEEE and The
       Open Group Standard is the referee document. The original Standard can
       be obtained online at http://www.opengroup.org/unix/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                             UMASK(1)
