1mkdir(1)                         User Commands                        mkdir(1)
2
3
4

NAME

6       mkdir - make directories
7

SYNOPSIS

9   /usr/bin/mkdir
10       /usr/bin/mkdir [-m mode] [-p] dir...
11
12
13   ksh93
14       mkdir [-p] [-m mode] dir...
15
16

DESCRIPTION

18   /usr/bin/mkdir
19       The  mkdir  command creates the named directories in mode 777 (possibly
20       altered by the file mode creation mask umask(1)).
21
22
23       Standard entries in a directory (for instance, the files ".",  for  the
24       directory  itself,  and  "..",  for its parent) are made automatically.
25       mkdir cannot create these entries by  name.  Creation  of  a  directory
26       requires write permission in the parent directory.
27
28
29       The  owner-ID  and  group-ID  of  the  new  directories  are set to the
30       process's effective user-ID and group-ID, respectively. mkdir calls the
31       mkdir(2) system call.
32
33   setgid and mkdir
34       To  change  the  setgid  bit on a newly created directory, you must use
35       chmod g+s or chmod g-s after executing mkdir.
36
37
38       The setgid bit setting is inherited from the parent directory.
39
40   ksh93
41       The mkdir built-in in ksh93 is associated with the  /bin  and  /usr/bin
42       paths.  It  is invoked when mkdir is executed without a pathname prefix
43       and the pathname search  finds  a  /bin/mkdir  or  /usr/bin/mkdir  exe‐
44       cutable. mkdir creates one or more directories. By default, the mode of
45       created directories is a=rwx minus the bits set in umask(1).
46

OPTIONS

48   /usr/bin/mkdir
49       The following options are supported by /usr/bin/mkdir:
50
51       -m mode    This option allows users to specify the mode to be used  for
52                  new directories. Choices for modes can be found in chmod(1).
53
54
55       -p         With this option, mkdir creates dir by creating all the non-
56                  existing parent directories first. The mode given to  inter‐
57                  mediate  directories  is  the difference between 777 and the
58                  bits set in the file mode  creation  mask.  The  difference,
59                  however,  must be at least 300 (write and execute permission
60                  for the user).
61
62
63   ksh93
64       The following options are supported by the mkdir built-in in ksh93:
65
66       -m mode        Set the mode of created directories  to  mode.  mode  is
67       --mode=mode    symbolic  or  octal  mode as in chmod(1). Relative modes
68                      assume an initial mode of a=rwx.
69
70
71       -p             Create any missing intermediate pathname components. For
72       --parents      each  dir  operand that does not name an existing direc‐
73                      tory, effects equivalent to those caused by the  follow‐
74                      ing command shall occur:
75
76                        mkdir -p -m $(umask -S),u+wx \
77                             $(dirname dir) && mkdir [-m mode] dir
78
79
80                      Where the -m mode option represents that option supplied
81                      to the original invocation of mkdir, if  any.  Each  dir
82                      operand  that  names  an  existing  directory is ignored
83                      without error.
84
85

OPERANDS

87       The following operand is supported:
88
89       dir    A path name of a directory to be created.
90
91

USAGE

93       See largefile(5) for the description of  the  behavior  of  mkdir  when
94       encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
95

EXAMPLES

97       Example 1 Using mkdir
98
99
100       The following example:
101
102
103         example% mkdir -p ltr/jd/jan
104
105
106
107
108       creates the subdirectory structure ltr/jd/jan.
109
110

ENVIRONMENT VARIABLES

112       See  environ(5) for descriptions of the following environment variables
113       that affect the execution of mkdir:  LANG,  LC_ALL,  LC_CTYPE,  LC_MES‐
114       SAGES, and NLSPATH.
115

EXIT STATUS

117       The following exit values are returned:
118
119       0     All the specified directories were created successfully or the -p
120             option was specified and all the specified directories now exist.
121
122
123       >0    An error occurred.
124
125

ATTRIBUTES

127       See attributes(5) for descriptions of the following attributes:
128
129   /usr/bin/mkdir
130       ┌─────────────────────────────┬─────────────────────────────┐
131       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
132       ├─────────────────────────────┼─────────────────────────────┤
133       │Availability                 │SUNWcsu                      │
134       ├─────────────────────────────┼─────────────────────────────┤
135       │CSI                          │Enabled                      │
136       ├─────────────────────────────┼─────────────────────────────┤
137       │Interface Stability          │Committed                    │
138       ├─────────────────────────────┼─────────────────────────────┤
139       │Standard                     │See standards(5).            │
140       └─────────────────────────────┴─────────────────────────────┘
141
142   ksh93
143       ┌─────────────────────────────┬─────────────────────────────┐
144       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
145       ├─────────────────────────────┼─────────────────────────────┤
146       │Availability                 │SUNWcsu                      │
147       ├─────────────────────────────┼─────────────────────────────┤
148       │Interface Stability          │See below.                   │
149       ├─────────────────────────────┼─────────────────────────────┤
150       │Standard                     │See standards(5).            │
151       └─────────────────────────────┴─────────────────────────────┘
152
153
154       The ksh93 built-in binding to /bin and /usr/bin is Volatile. The built-
155       in interfaces are Uncommitted.
156

SEE ALSO

158       chmod(1),   ksh93(1),   rm(1),  sh(1),  umask(1),  Intro(2),  mkdir(2),
159       attributes(5), environ(5), largefile(5), standards(5)
160
161
162
163SunOS 5.11                        2 Nov 2007                          mkdir(1)
Impressum