1MKDIR(P)                   POSIX Programmer's Manual                  MKDIR(P)
2
3
4

NAME

6       mkdir - make directories
7

SYNOPSIS

9       mkdir [-p][-m mode] dir...
10

DESCRIPTION

12       The  mkdir  utility shall create the directories specified by the oper‐
13       ands, in the order specified.
14
15       For each dir operand, the mkdir utility shall perform  actions  equiva‐
16       lent to the mkdir() function defined in the System Interfaces volume of
17       IEEE Std 1003.1-2001, called with the following arguments:
18
19        1. The dir operand is used as the path argument.
20
21        2. The value of the bitwise-inclusive  OR  of  S_IRWXU,  S_IRWXG,  and
22           S_IRWXO  is  used as the mode argument. (If the -m option is speci‐
23           fied, the mode option-argument overrides this default.)
24

OPTIONS

26       The mkdir utility shall conform  to  the  Base  Definitions  volume  of
27       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
28
29       The following options shall be supported:
30
31       -m  mode
32              Set  the  file permission bits of the newly-created directory to
33              the specified mode value. The mode option-argument shall be  the
34              same  as  the mode operand defined for the chmod utility. In the
35              symbolic_mode strings, the op characters '+' and  '-'  shall  be
36              interpreted  relative  to an assumed initial mode of a= rwx; '+'
37              shall add permissions to the default mode, '-' shall delete per‐
38              missions from the default mode.
39
40       -p     Create any missing intermediate pathname components.
41
42       For  each dir operand that does not name an existing directory, effects
43       equivalent to those caused by the following command shall occur:
44
45
46              mkdir -p -m $(umask -S),u+wx $(dirname dir) &&
47              mkdir [-m mode] dir
48
49       where the -m mode option represents that option supplied to the  origi‐
50       nal invocation of mkdir, if any.
51
52       Each  dir  operand  that  names  an existing directory shall be ignored
53       without error.
54
55

OPERANDS

57       The following operand shall be supported:
58
59       dir    A pathname of a directory to be created.
60
61

STDIN

63       Not used.
64

INPUT FILES

66       None.
67

ENVIRONMENT VARIABLES

69       The following environment  variables  shall  affect  the  execution  of
70       mkdir:
71
72       LANG   Provide  a  default value for the internationalization variables
73              that are unset or null. (See  the  Base  Definitions  volume  of
74              IEEE Std 1003.1-2001,  Section  8.2,  Internationalization Vari‐
75              ables for the precedence of internationalization variables  used
76              to determine the values of locale categories.)
77
78       LC_ALL If  set  to a non-empty string value, override the values of all
79              the other internationalization variables.
80
81       LC_CTYPE
82              Determine the locale for  the  interpretation  of  sequences  of
83              bytes  of  text  data as characters (for example, single-byte as
84              opposed to multi-byte characters in arguments).
85
86       LC_MESSAGES
87              Determine the locale that should be used to  affect  the  format
88              and contents of diagnostic messages written to standard error.
89
90       NLSPATH
91              Determine the location of message catalogs for the processing of
92              LC_MESSAGES .
93
94

ASYNCHRONOUS EVENTS

96       Default.
97

STDOUT

99       Not used.
100

STDERR

102       The standard error shall be used only for diagnostic messages.
103

OUTPUT FILES

105       None.
106

EXTENDED DESCRIPTION

108       None.
109

EXIT STATUS

111       The following exit values shall be returned:
112
113        0     All the specified directories were created successfully  or  the
114              -p  option  was  specified and all the specified directories now
115              exist.
116
117       >0     An error occurred.
118
119

CONSEQUENCES OF ERRORS

121       Default.
122
123       The following sections are informative.
124

APPLICATION USAGE

126       The default file mode for directories is a= rwx (777 on  most  systems)
127       with selected permissions removed in accordance with the file mode cre‐
128       ation mask. For intermediate pathname components created by mkdir,  the
129       mode  is  the  default modified by u+ wx so that the subdirectories can
130       always be created regardless of the file mode creation mask; if differ‐
131       ent  ultimate permissions are desired for the intermediate directories,
132       they can be changed afterwards with chmod.
133
134       Note that some of the requested directories may have been created  even
135       if an error occurs.
136

EXAMPLES

138       None.
139

RATIONALE

141       The System V -m option was included to control the file mode.
142
143       The  System  V -p option was included to create any needed intermediate
144       directories and to complement the functionality provided by  rmdir  for
145       removing  directories in the path prefix as they become empty.  Because
146       no error is produced if any  path  component  already  exists,  the  -p
147       option is also useful to ensure that a particular directory exists.
148
149       The  functionality of mkdir is described substantially through a refer‐
150       ence to the  mkdir()  function  in  the  System  Interfaces  volume  of
151       IEEE Std 1003.1-2001.  For  example, by default, the mode of the direc‐
152       tory is affected by the file mode creation mask in accordance with  the
153       specified  behavior of the mkdir() function. In this way, there is less
154       duplication of effort required for describing details of the  directory
155       creation.
156

FUTURE DIRECTIONS

158       None.
159

SEE ALSO

161       chmod()  ,  rm  ,  rmdir()  , umask() , the System Interfaces volume of
162       IEEE Std 1003.1-2001, mkdir()
163
165       Portions of this text are reprinted and reproduced in  electronic  form
166       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
167       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
168       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
169       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
170       event of any discrepancy between this version and the original IEEE and
171       The Open Group Standard, the original IEEE and The Open Group  Standard
172       is  the  referee document. The original Standard can be obtained online
173       at http://www.opengroup.org/unix/online.html .
174
175
176
177IEEE/The Open Group                  2003                             MKDIR(P)
Impressum