2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
45 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
46 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
48 .TH MKDIR 1 "Nov 2, 2007"
50 mkdir \- make directories
55 \fB/usr/bin/mkdir\fR [\fB-m\fR \fImode\fR] [\fB-p\fR] \fIdir\fR...
61 \fBmkdir\fR [\fB-p\fR] [\fB-m\fR \fImode\fR] \fIdir\fR...
68 The \fBmkdir\fR command creates the named directories in mode \fB777\fR
69 (possibly altered by the file mode creation mask \fBumask\fR(1)).
72 Standard entries in a directory (for instance, the files "\fB\&.\fR", for the
73 directory itself, and "\fB\&.\|.\fR", for its parent) are made automatically.
74 \fBmkdir\fR cannot create these entries by name. Creation of a directory
75 requires write permission in the parent directory.
78 The owner-ID and group-ID of the new directories are set to the process's
79 effective user-ID and group-ID, respectively. \fBmkdir\fR calls the
80 \fBmkdir\fR(2) system call.
81 .SS "setgid and mkdir"
84 To change the \fBsetgid\fR bit on a newly created directory, you must use
85 \fBchmod\fR \fBg+s\fR or \fBchmod\fR \fBg-s\fR after executing \fBmkdir\fR.
88 The \fBsetgid\fR bit setting is inherited from the parent directory.
92 The \fBmkdir\fR built-in in \fBksh93\fR is associated with the \fB/bin\fR and
93 \fB/usr/bin\fR paths. It is invoked when \fBmkdir\fR is executed without a
94 pathname prefix and the pathname search finds a \fB/bin/mkdir\fR or
95 \fB/usr/bin/mkdir\fR executable. \fBmkdir\fR creates one or more directories.
96 By default, the mode of created directories is \fBa=rwx\fR minus the bits set
102 The following options are supported by \fB/usr/bin/mkdir\fR:
106 \fB\fB-m\fR \fImode\fR\fR
109 This option allows users to specify the mode to be used for new directories.
110 Choices for modes can be found in \fBchmod\fR(1).
119 With this option, \fBmkdir\fR creates \fIdir\fR by creating all the
120 non-existing parent directories first. The mode given to intermediate
121 directories is the difference between \fB777\fR and the bits set in the file
122 mode creation mask. The difference, however, must be at least \fB300\fR (write
123 and execute permission for the user).
129 The following options are supported by the \fBmkdir\fR built-in in \fBksh93\fR:
133 \fB\fB-m\fR \fImode\fR\fR
137 \fB\fB--mode=\fR\fImode\fR\fR
140 Set the mode of created directories to \fImode\fR. \fImode\fR is symbolic or
141 octal mode as in \fBchmod\fR(1). Relative modes assume an initial mode of
152 \fB\fB--parents\fR\fR
155 Create any missing intermediate pathname components. For each dir operand that
156 does not name an existing directory, effects equivalent to those caused by the
157 following command shall occur:
161 mkdir -p -m $(umask -S),u+wx \e
162 $(dirname dir) && mkdir [-m mode] dir
167 Where the \fB-m\fR mode option represents that option supplied to the original
168 invocation of \fBmkdir\fR, if any. Each \fBdir\fR operand that names an
169 existing directory is ignored without error.
175 The following operand is supported:
182 A path name of a directory to be created.
187 \fBExample 1 \fRUsing \fBmkdir\fR
190 The following example:
195 example% \fBmkdir -p ltr/jd/jan\fR
202 creates the subdirectory structure \fBltr/jd/jan\fR.
204 .SH ENVIRONMENT VARIABLES
207 See \fBenviron\fR(5) for descriptions of the following environment variables
208 that affect the execution of \fBmkdir\fR: \fBLANG\fR, \fBLC_ALL\fR,
209 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
213 The following exit values are returned:
220 All the specified directories were created successfully or the \fB-p\fR option
221 was specified and all the specified directories now exist.
236 See \fBattributes\fR(5) for descriptions of the following attributes:
245 ATTRIBUTE TYPE ATTRIBUTE VALUE
249 Interface Stability Committed
251 Standard See \fBstandards\fR(5).
262 ATTRIBUTE TYPE ATTRIBUTE VALUE
264 Interface Stability See below.
266 Standard See \fBstandards\fR(5).
271 The \fBksh93\fR built-in binding to \fB/bin\fR and \fB/usr/bin\fR is Volatile.
272 The built-in interfaces are Uncommitted.
276 \fBchmod\fR(1), \fBksh93\fR(1), \fBrm\fR(1), \fBsh\fR(1), \fBumask\fR(1),
277 \fBIntro\fR(2), \fBmkdir\fR(2), \fBattributes\fR(5), \fBenviron\fR(5),