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 unless specified otherwise by a -m mode option (see umask(1)). Standard entries, . (for the directory itself) and .. (for its parent) are created automatically. If dirname already exists, mkdir exits with a diagnostic message, and the directory is not changed.
Options
mkdir recognizes the following command-line 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 (see 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 directory name in the pathname prefix of the dirname argument that is not the name of an existing directory, the specified directory is created using the current umask setting, 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. Each directory name in the pathname prefix of the dirname argument that matches an existing directory 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. If the dirname argument (including pathname prefix) names an existing directory, mkdir fails with an error message.
If the -m option is used, the directory specified by dirname (excluding directories in the pathname prefix) is created with the permissions specified by mode.
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.
DIAGNOSTICS
mkdir returns exit code 0 if all directories were successfully made. Otherwise, it prints a diagnostic and returns non-zero.
EXAMPLES
Create directory gem beneath existing directory raw in the current directory:
mkdir raw/gem
Create directory path raw/gem/diamond underneath the current directory and set permissions on directory diamond to read-only for all users (a=r):
mkdir -p -m "a=r" raw/gem/diamond
which is equivalent to (see chmod(1)):
mkdir -p -m 444 raw/gem/diamond
If directories raw or raw and gem already exist, only the missing directories in the specified path are created.
SEE ALSO
STANDARDS CONFORMANCE
mkdir: SVID2, XPG2, XPG3, POSIX.2
Hewlett-Packard Company — HP-UX Release 9.0: August 1992