MKDIR(1) General Commands Manual MKDIR(1)

mkdircreate directory

mkdir [-pv] [-m mode] [-Z|--context[=MAC]] directory

Creates the specified directories with mode a=rwx - umask.

With -p, creates all leading directories, too, with the permission bits of u=wx + ~umask. This ensures the final directory can be created, regardless of ill-advised umasks.

, --parents
Create all parents of the specified directories as well, and ignore directories that already exist.
, --verbose
Write which directories were created to the standard output stream.
, --mode=mode
chmod(1)-style mode to create final directories as.
, --context
Create directories with the default SELinux contexts for their paths. Ignored without SELinux.
=MAC
Create directories with SELinux context set to MAC. Ignored (diagnostic issued) without SELinux.

if a directory (or its parent with -p) couldn't be created, except for when it's because of EEXIST, the path is a directory, and -p was specified.

rmdir(1), mkdir(2)

mkdir conforms to IEEE Std 1003.1-2008 (“POSIX.1”). --context and -v are extensions, also present on the GNU system.

Appears in the first edition of the UNIX Programmer's Manual as mkdir(I):

Which bypassed permissions and made the "system's user ID" the owner of the directory.

Second and later editions fix the bugs, note the mode being 17 (read+write owner+non-owner), and expand the SYNOPSIS to

mkdir dirname ...

AT&T System V Release 3 UNIX adds -m octal and -p (with parents in the same mode as the destination). 4.3BSD-Reno adds -p (with parents as 777 - umask).

IEEE Std 1003.2-1992 (“POSIX.2”) specifies -mp in their current form, and such they appear in 4.4BSD-Lite2.

June 9, 2023 voreutils pre-v0.0.0-latest