mkdir(1)
NAME
mkdir − make a directory
SYNOPSIS
mkdir [−p] [−m mode] dirname ...
DESCRIPTION
mkdir creates specified directories in mode 0777 (possibly altered by umask(1)) unless specified otherwise by mode. Standard entries, ., for the directory itself, and .., for its parent, are made automatically. If dirname already exists, mkdir exits with a diagnostic message, and the directory is not changed.
Options
−m mode After creating the directory as specified, the file permissions are set to mode, which is a symbolic mode string as defined for chmod(1).
−p Intermediate directories are created as necessary. Otherwise, the full path prefix of dirname must already exist. mkdir requires write permission in the parent directory.
For each component of the dir operand that does not name an existing directory, the directory named by that component is created with mode 0777, except that the equivalent of chmod u+wx is done on each component to ensure that mkdir can create lower directories regardless of the setting of umask. For each component of dir that names an existing directory, except the last component, that component is ignored without error. If an intermediate path component exists but has permissions set to prevent writing or searching, mkdir fails with an error message. Only LINK_MAX subdirectories can be created (see limits(5)).
EXTERNAL INFLUENCES
Environment Variables
LANG determines the language in which messages are displayed.
If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG.
If any internationalization variable contains an invalid setting, mkdir behaves as if all internationalization variables are set to "C". See environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported.
EXAMPLES
The following command creates the directory gem beneath directory raw:
mkdir raw/gem
Note that directory raw must already exist, and it must be a subdirectory of the current working directory.
The following command creates the directory diamond beneath directory gem which is beneath directory raw and gives directory diamond read-only permissions:
mkdir -p -m a=r raw/gem/diamond
which is equivalent to (see chmod(1)):
mkdir -p -m 444 raw/gem/diamond
None of the directories need have existed before the command was issued.
SEE ALSO
DIAGNOSTICS
mkdir returns exit code 0 if all directories were successfully made. Otherwise, it prints a diagnostic and returns non-zero.
STANDARDS CONFORMANCE
mkdir: SVID2, XPG2, XPG3, proposed POSIX.2 FIPS (June 1990)
Hewlett-Packard Company — HP-UX Release 8.05: June 1991