MKDIR(1POSIX)
π PROLOG π
okay bestie, heads up before we even start: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface might not even be implemented on Linux at all. no cap. π
β¨ NAME β¨
mkdir β make directories π
(yes that's it, that's the whole job, and it eats every time)
π SYNOPSIS π
mkdir [-p] [-m mode] dir...
πΈ DESCRIPTION πΈ
so the mkdir utility shall create the directories you name in the operands, in the order specified. order matters, bestie, it's giving very particular.
for each dir operand, mkdir shall do stuff equivalent to the mkdir() function defined in the System Interfaces volume of POSIX.1β2017, called with these arguments:
- the dir operand is used as the path argument.
- the value of the bitwise-inclusive OR of
S_IRWXU,S_IRWXG, andS_IRWXOis used as the mode argument. (and if the-moption is specified, the value of themkdir()mode argument is unspecified β like, genuinely unspecified β but the directory shall at no time have permissions less restrictive than the-mmode option-argument. so it can be stricter than you asked? no. never looser. π«Ά)
π OPTIONS π
the mkdir utility shall conform to the Base Definitions volume of POSIX.1β2017, Section 12.2, Utility Syntax Guidelines. icon behavior only.
the following options shall be supported:
-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 thechmodutility. in the symbolic_mode strings, the op characters'+'and'-'shall be interpreted relative to an assumed initial mode ofa=rwx;'+'shall add permissions to the default mode, and'-'shall delete permissions from the default mode. so like, you're editing a starting point of everything, not starting from nothing. noted. π-pβ create any missing intermediate pathname components. the mom-friend flag fr.
for each dir operand that does not name an existing directory, before performing the actions described in the DESCRIPTION above, the mkdir utility shall create any pathname components of the path prefix of dir that do not name an existing directory, by performing actions equivalent to first calling the mkdir() function with these arguments:
- a pathname naming the missing pathname component, ending with a trailing
<slash>character, as the path argument - the value zero as the mode argument
and then calling the chmod() function with these arguments:
- the same path argument as in the
mkdir()call - the value
(S_IWUSR|S_IXUSR|~filemask)&0777as the mode argument, where filemask is the file mode creation mask of the process (see the System Interfaces volume of POSIX.1β2017,umask())
each dir operand that names an existing directory shall be ignored without error. no drama, no complaints, just vibes. π
π¦ OPERANDS π¦
the following operand shall be supported:
- dir β a pathname of a directory to be created. that's the one, that's the assignment.
π STDIN π
not used. she doesn't read, she just creates. π
π INPUT FILES π
none.
π§ ENVIRONMENT VARIABLES π§
the following environment variables shall affect the execution of mkdir:
LANGβ provide a default value for the internationalization variables that are unset or null. (see the Base Definitions volume of POSIX.1β2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)LC_ALLβ if set to a non-empty string value, override the values of all the other internationalization variables. main character energy, overrides everyone.LC_CTYPEβ determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte 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 catalogs for the processing ofLC_MESSAGES.
β ASYNCHRONOUS EVENTS β
default.
π STDOUT π
not used. no output, just results. silent queen.
πΈ STDERR πΈ
the standard error shall be used only for diagnostic messages.
π OUTPUT FILES π
none.
β¨ EXTENDED DESCRIPTION β¨
none.
π EXIT STATUS π
the following exit values shall be returned:
0β all the specified directories were created successfully, or the-poption was specified and all the specified directories either already existed or were created successfully.>0β an error occurred. π
π₯ CONSEQUENCES OF ERRORS π₯
default.
the following sections are informative. (translation: the next bits are lore, not rules.)
π 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.
also note: some of the requested directories may have been created even if an error occurs. so like, check before you assume nothing happened. π
π¦ EXAMPLES π¦
none.
π RATIONALE π
the System V -m option was included to control the file mode.
the System V -p option was included to create any needed intermediate directories and to complement the functionality provided by 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 the System Interfaces volume of POSIX.1β2017. for example, by default, the mode of the directory is affected by the file mode creation mask in accordance with the specified behavior of the mkdir() function. this way, there is less duplication of effort required for describing details of the directory creation. efficiency, we love her. π
β FUTURE DIRECTIONS β
none.
π SEE ALSO π
chmod, rm, rmdir, umask
the Base Definitions volume of POSIX.1β2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
the System Interfaces volume of POSIX.1β2017, mkdir(), umask()
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie β brought to you by IEEE/The Open Group, dated 2017, filed under MKDIR(1POSIX). go forth and make directories, ily π«Άπβ¨
π¦ where this page comes from
- debian bookworm: manpages-posix 2017a-2 Β· Other
- debian trixie: manpages-posix 2017a-2 Β· Other
- ubuntu jammy: manpages-posix 2017a-2 Β· Other
- ubuntu noble: manpages-posix 2017a-2 Β· Other
- ubuntu resolute: manpages-posix 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms