The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

mkdir - make directories

 SYNOPSIS



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

 DESCRIPTION

The mkdir utility will create the directories specified by the operands, in the order specified.

For each dir operand, the mkdir utility will perform actions equivalent to the XSH specification mkdir() function, called with the following arguments:

  1. The dir operand is used as the path argument.

  2. The value of the bitwise inclusive OR of S_IRWXU, S_IRWXG and S_IRWXO is used as the mode argument. (If the -m option is specified, the mode option-argument overrides this default.)

 OPTIONS

The mkdir utility supports the XBD specification, Utility Syntax Guidelines  .

The following options are supported:

-m mode
Set the file permission bits of the newly-created directory to the specified mode value. The mode option-argument will be the same as the mode operand defined for the chmod utility. In the symbolic_mode strings, the op characters "+" and "-" will be interpreted relative to an assumed initial mode of a=rwx; "+" will add permissions to the default mode, "-" will delete permissions from the default mode.
-p
Create any missing intermediate pathname components. For each dir operand that does not name an existing directory, effects equivalent to those caused by the following command will occur:

mkdir -p -m $(umask -S),u+wx $(dirname dir) &&
mkdir [-m mode] dir

where the [-m mode] option represents that option supplied to the original invocation of mkdir, if any. Each dir operand that names an existing directory will be ignored without error.

 OPERANDS

The following operand is supported:
dir
A pathname of a directory to be created.

 STDIN

Not used.

 INPUT FILES

None.

 ENVIRONMENT VARIABLES

The following environment variables affect the execution of mkdir:
LANG
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
LC_ALL
If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
NLSPATH
Determine the location of message catalogues for the processing of LC_MESSAGES .

 ASYNCHRONOUS EVENTS

Default.

 STDOUT

Not used.

 STDERR

Used only for diagnostic messages.

 OUTPUT FILES

None.

 EXTENDED DESCRIPTION

None.

 EXIT STATUS

The following exit values are returned:
0
All the specified directories were created successfully or the -p option was specified and all the specified directories now exist.
>0
An error occurred.

 CONSEQUENCES OF ERRORS

Default.

 APPLICATION USAGE

The default file mode for directories is a=rwx (777 on most systems) with selected permissions removed in accordance with the file mode creation mask. For intermediate pathname components created by mkdir, the mode is the default modified by u+wx so that the subdirectories can always be created regardless of the file mode creation mask; if different ultimate permissions are desired for the intermediate directories, they can be changed afterwards with chmod.

Note that some of the requested directories may have been created even if an error occurs.

 EXAMPLES

None.

 FUTURE DIRECTIONS

The IEEE PASC 1003.2 Interpretations Committee has forwarded concerns about parts of this interface definition to the IEEE PASC Shell and Utilities Working Group which is identifying the corrections. A future revision of this specification will align with IEEE Std. 1003.2b when finalised.

 SEE ALSO

rm, rmdir, umask, the XSH specification description of mkdir().

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]