NAME
mkdir — make
directories
SYNOPSIS
mkdir |
[-p] [-m
mode] dir
... |
DESCRIPTION
The mkdir utility shall create the
directories specified by the operands, in the order specified. For each dir
operand, the mkdir utility shall perform actions
equivalent to the POSIX. 1 {8}
mkdir function, called with the following
arguments:
OPTIONS
The mkdir utility shall conform to the
utility argument syntax guidelines described in 2.10.2. The following
options shall be supported by the implementation:
-mmode-
Set the file permission bits of the newly-created directory to the specified mode value. The mode option-argument shall be the same as the mode operand defined for the chmod utility (see chmod(1) ). In the symbolic_mode strings, the op characters + and - shall be interpreted relative to an assumed initial mode of a=rwx; + shall add permissions to the default mode, - shall 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 following command shall 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 ofmkdir, if any. Each dir operand that names an existing directory shall be ignored without error.
OPERANDS
The following operand shall be supported by the implementation:
- dir
-
A pathname of a directory to be created.
STANDARD INPUT
None.
INPUT FILES
None.
ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of
mkdir:
LANG-
This variable shall determine the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_ ) do not specify a locale. See 2.6.
LC_ALL-
This variable shall determine the locale to be used to override any values for locale categories specified by the settings of LANG or any environment variables beginning with LC_.
LC_CTYPE-
This variable shall determine the locale for the interpretation of sequences of bytes of text data as characters (e.g., single- versus multibyte characters in arguments).
LC_MESSAGES-
This variable shall determine the language in which messages should be written.
ASYNCHRONOUS EVENTS
Default.
STANDARD OUTPUT
None.
STANDARD ERROR
Used only for diagnostic messages.
OUTPUT FILES
None.
EXTENDED DESCRIPTION
None.
EXIT STATUS
The mkdir utility shall exit with one of
the following values:
CONSEQUENCES OF ERRORS
Default.
RATIONALE
EXAMPLES
The default file mode for directories is a=rwx (777) with selected
permissions removed in accordance with the file mode creation mask. For
intermediate path name 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 afterward with chmod. Application writers should note that some
of the requested directories may have been created even if an error
occurs.
HISTORY OF DECISIONS MADE
The System V −m option was added to control the file mode.
The System V −p option was added to create any needed intermediate
directories, to complement the functionality provided rmdir for removing
directories in the path prefix as they become empty. Because no error is
produced if any path component already exists, the −p option is also
useful to ensure that a particular directory exists. The functionality of
mkdir is described substantially through a reference
to the mkdir function in POSIX. 1
{8}. For example, by default, the mode of the directory is affected by the
file mode creation mask in accordance with the specified behavior of
POSIX. 1 {8} mkdir. In this way,
there is less duplication of effort required for describing details of the
directory creation.