1MKDIR(1P) POSIX Programmer's Manual MKDIR(1P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 mkdir - make directories
13
15 mkdir [-p][-m mode] dir...
16
18 The mkdir utility shall create the directories specified by the oper‐
19 ands, in the order specified.
20
21 For each dir operand, the mkdir utility shall perform actions equiva‐
22 lent to the mkdir() function defined in the System Interfaces volume of
23 IEEE Std 1003.1-2001, called with the following arguments:
24
25 1. The dir operand is used as the path argument.
26
27 2. The value of the bitwise-inclusive OR of S_IRWXU, S_IRWXG, and
28 S_IRWXO is used as the mode argument. (If the -m option is speci‐
29 fied, the mode option-argument overrides this default.)
30
32 The mkdir utility shall conform to the Base Definitions volume of
33 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
34
35 The following options shall be supported:
36
37 -m mode
38 Set the file permission bits of the newly-created directory to
39 the specified mode value. The mode option-argument shall be the
40 same as the mode operand defined for the chmod utility. In the
41 symbolic_mode strings, the op characters '+' and '-' shall be
42 interpreted relative to an assumed initial mode of a= rwx; '+'
43 shall add permissions to the default mode, '-' shall delete per‐
44 missions from the default mode.
45
46 -p Create any missing intermediate pathname components.
47
48 For each dir operand that does not name an existing directory, effects
49 equivalent to those caused by the following command shall occur:
50
51
52 mkdir -p -m $(umask -S),u+wx $(dirname dir) &&
53 mkdir [-m mode] dir
54
55 where the -m mode option represents that option supplied to the origi‐
56 nal invocation of mkdir, if any.
57
58 Each dir operand that names an existing directory shall be ignored
59 without error.
60
61
63 The following operand shall be supported:
64
65 dir A pathname of a directory to be created.
66
67
69 Not used.
70
72 None.
73
75 The following environment variables shall affect the execution of
76 mkdir:
77
78 LANG Provide a default value for the internationalization variables
79 that are unset or null. (See the Base Definitions volume of
80 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
81 ables for the precedence of internationalization variables used
82 to determine the values of locale categories.)
83
84 LC_ALL If set to a non-empty string value, override the values of all
85 the other internationalization variables.
86
87 LC_CTYPE
88 Determine the locale for the interpretation of sequences of
89 bytes of text data as characters (for example, single-byte as
90 opposed to multi-byte characters in arguments).
91
92 LC_MESSAGES
93 Determine the locale that should be used to affect the format
94 and contents of diagnostic messages written to standard error.
95
96 NLSPATH
97 Determine the location of message catalogs for the processing of
98 LC_MESSAGES .
99
100
102 Default.
103
105 Not used.
106
108 The standard error shall be used only for diagnostic messages.
109
111 None.
112
114 None.
115
117 The following exit values shall be returned:
118
119 0 All the specified directories were created successfully or the
120 -p option was specified and all the specified directories now
121 exist.
122
123 >0 An error occurred.
124
125
127 Default.
128
129 The following sections are informative.
130
132 The default file mode for directories is a= rwx (777 on most systems)
133 with selected permissions removed in accordance with the file mode cre‐
134 ation mask. For intermediate pathname components created by mkdir, the
135 mode is the default modified by u+ wx so that the subdirectories can
136 always be created regardless of the file mode creation mask; if differ‐
137 ent ultimate permissions are desired for the intermediate directories,
138 they can be changed afterwards with chmod.
139
140 Note that some of the requested directories may have been created even
141 if an error occurs.
142
144 None.
145
147 The System V -m option was included to control the file mode.
148
149 The System V -p option was included to create any needed intermediate
150 directories and to complement the functionality provided by rmdir for
151 removing directories in the path prefix as they become empty. Because
152 no error is produced if any path component already exists, the -p
153 option is also useful to ensure that a particular directory exists.
154
155 The functionality of mkdir is described substantially through a refer‐
156 ence to the mkdir() function in the System Interfaces volume of
157 IEEE Std 1003.1-2001. For example, by default, the mode of the direc‐
158 tory is affected by the file mode creation mask in accordance with the
159 specified behavior of the mkdir() function. In this way, there is less
160 duplication of effort required for describing details of the directory
161 creation.
162
164 None.
165
167 chmod(), rm, rmdir(), umask(), the System Interfaces volume of
168 IEEE Std 1003.1-2001, mkdir()
169
171 Portions of this text are reprinted and reproduced in electronic form
172 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
173 -- Portable Operating System Interface (POSIX), The Open Group Base
174 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
175 Electrical and Electronics Engineers, Inc and The Open Group. In the
176 event of any discrepancy between this version and the original IEEE and
177 The Open Group Standard, the original IEEE and The Open Group Standard
178 is the referee document. The original Standard can be obtained online
179 at http://www.opengroup.org/unix/online.html .
180
181
182
183IEEE/The Open Group 2003 MKDIR(1P)