The
mkdir
(make directory)
command
Command may refer to:
Computing
* Command (computing), a statement in a computer language
* COMMAND.COM, the default operating system shell and command-line interpreter for DOS
* Command key, a modifier key on Apple Macintosh computer keyboards
* ...
in the
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, an ...
,
DOS
DOS is shorthand for the MS-DOS and IBM PC DOS family of operating systems.
DOS may also refer to:
Computing
* Data over signalling (DoS), multiplexing data onto a signalling channel
* Denial-of-service attack (DoS), an attack on a communicat ...
,
DR FlexOS
FlexOS is a discontinued modular real-time multiuser multitasking operating system (RTOS) designed for computer-integrated manufacturing, laboratory, retail and financial markets. Developed by Digital Research's Flexible Automation Business U ...
,
IBM OS/2
OS/2 (Operating System/2) is a series of computer operating systems, initially created by Microsoft and IBM under the leadership of IBM software designer Ed Iacobucci. As a result of a feud between the two companies over how to position OS/2 r ...
,
Microsoft Windows, and
ReactOS operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.
Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
s is used to make a new
directory. It is also available in the
EFI shell and in the
PHP
PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by The PHP Group. ...
scripting language
A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled.
A scripting ...
. In DOS, OS/2, Windows and ReactOS, the command is often abbreviated to
md
.
The command is analogous to the
Stratus
Stratus may refer to:
Weather
*Stratus cloud, a cloud type
**Nimbostratus cloud, a cloud type
**Stratocumulus cloud, a cloud type
**Altostratus cloud, a cloud type
**Altostratus undulatus cloud, a cloud type
**Cirrostratus cloud, a cloud type
Mus ...
OpenVOS create_dir
command.
MetaComCo TRIPOS
At the University of Cambridge, a Tripos (, plural 'Triposes') is any of the examinations that qualify an undergraduate for a bachelor's degree or the courses taken by a student to prepare for these. For example, an undergraduate studying mathe ...
and
AmigaDOS provide a similar
MakeDir
command to create new directories. The
numerical computing environments
MATLAB
MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementa ...
and
GNU Octave
GNU Octave is a high-level programming language primarily intended for scientific computing and numerical computation. Octave helps in solving linear and nonlinear problems numerically, and for performing other numerical experiments using a langu ...
include an
mkdir
function with similar functionality.
History
In early versions of Unix (
4.1BSD and early versions of
System V
Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
), this command had to be
setuid
The Unix access rights flags setuid and setgid (short for ''set user identity'' and ''set group identity'') allow users to run an executable with the file system permissions of the executable's owner or group respectively and to change behaviour ...
root
In vascular plants, the roots are the organs of a plant that are modified to provide anchorage for the plant and take in water and nutrients into the plant body, which allows plants to grow taller and faster. They are most often below the su ...
as the
kernel
Kernel may refer to:
Computing
* Kernel (operating system), the central component of most operating systems
* Kernel (image processing), a matrix used for image convolution
* Compute kernel, in GPGPU programming
* Kernel method, in machine learn ...
did not have an
mkdir
syscall
In computing, a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the operating system on which it is executed. This may include hardware-related services (for example, acc ...
. Instead, it made the directory with
mknod
and linked in the
.
and
..
directory entries manually. The command is available in
MS-DOS
MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few ope ...
versions 2 and later.
Digital Research
Digital Research, Inc. (DR or DRI) was a company created by Gary Kildall to market and develop his CP/M operating system and related 8-bit, 16-bit and 32-bit systems like MP/M, Concurrent DOS, FlexOS, Multiuser DOS, DOS Plus, DR DOS and Gr ...
DR DOS 6.0
DR-DOS (written as DR DOS, without a hyphen, in versions up to and including 6.0) is a disk operating system for IBM PC compatibles. Upon its introduction in 1988, it was the first DOS attempting to be compatible with IBM PC DOS and MS-D ...
and
Datalight
Datalight was a privately held software company specializing in power failsafe and high performance software for preserving data integrity in embedded systems. The company was founded in 1983 by Roy Sherrill, and is headquartered in Bothell, Was ...
ROM-DOS
Datalight was a privately held software company specializing in power failsafe and high performance software for preserving data integrity in embedded systems. The company was founded in 1983 by Roy Sherrill, and is headquartered in Bothell, Was ...
also include an implementation of the and commands.
The version of
mkdir
bundled in
GNU
GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
coreutils
The GNU Core Utilities or coreutils is a package of GNU software containing implementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems.
In September 2002, the ''GNU coreutils'' were cr ...
was written by David MacKenzie.
It is also available in the
open source MS-DOS
emulator
In computing, an emulator is hardware or software that enables one computer system (called the ''host'') to behave like another computer system (called the ''guest''). An emulator typically enables the host system to run software or use pe ...
DOSBox
DOSBox is a free and open-source emulator which runs software for MS-DOS compatible disk operating systems—primarily video games. It was first released in 2002, when DOS technology was becoming obsolete. Its adoption for running DOS games i ...
and in
KolibriOS
KolibriOS, or Kolibri, is a small, open-source x86 operating system written completely in assembly. It was forked from MenuetOS in 2004 and has run under independent development since.
In a 2009 review piece on alternative operating systems, ...
.
Usage
Normal usage is as straightforward as follows:
mkdir name_of_directory
where
name_of_directory
is the name of the directory one wants to create. When typed as above (i.e. normal usage), the new directory would be created within the current directory. On Unix and Windows (with Command extensions enabled, the default
), multiple directories can be specified, and
mkdir
will try to create all of them.
Options
On Unix-like operating systems,
mkdir
takes options. The options are:
*
-p (--parents)
: ''parents'' or ''path'', will also create all directories leading up to the given directory that do not exist already. For example,
mkdir -p a/b
will create directory
a
if it doesn't exist, then will create directory
b
inside directory
a
. If the given directory already exists, ignore the error.
*
-m (--mode)
: ''mode'', specify the
octal permissions of directories created by
mkdir
.
-p
is most often used when using
mkdir
to build up complex directory hierarchies, in case a necessary directory is missing or already there.
-m
is commonly used to lock down temporary directories used by
shell scripts.
Examples
An example of
-p
in action is:
mkdir -p /tmp/a/b/c
If
/tmp/a
exists but
/tmp/a/b
does not,
mkdir
will create
/tmp/a/b
before creating
/tmp/a/b/c
.
And an even more powerful command, creating a full tree at once (this however is a
Shell
Shell may refer to:
Architecture and design
* Shell (structure), a thin structure
** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses
** Thin-shell structure
Science Biology
* Seashell, a hard o ...
extension, nothing mkdir does itself):
mkdir -p tmpdir/
If one is using variables with mkdir in a bash script,
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inter ...
`special' built-in command 'eval' would serve its purpose.
DOMAIN_NAME=includes,docs
eval "mkdir -p tmpdir/"
This will create:
tmpdir
________, ______
, , ,
branches tags trunk
,
sources
____, _____
, ,
includes docs
See also
*
Filesystem Hierarchy Standard
*
GNU Core Utilities
The GNU Core Utilities or coreutils is a package of GNU software containing implementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems.
In September 2002, the ''GNU coreutils'' were ...
*
Find
Find, FIND or Finding may refer to:
Computing
* find (Unix), a command on UNIX platforms
* find (Windows), a command on DOS/Windows platforms
Books
* ''The Find'' (2010), by Kathy Page
* ''The Find'' (2014), by William Hope Hodgson
Film and t ...
– The find command coupled with mkdir can be used to only recreate a directory structure (without files).
*
List of Unix commands
This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems.
List
See also
* List of G ...
*
List of DOS commands
This article presents a list of commands used by DOS operating systems, especially as used on x86-based IBM PC compatibles (PCs). Other DOS operating systems are not part of the scope of this list.
In DOS, many standard system commands were pro ...
References
Further reading
*
*
*
*
External links
Microsoft TechNet Mkdir article*
*
*
{{Windows commands
Unix SUS2008 utilities
Plan 9 commands
Inferno (operating system) commands
Internal DOS commands
MSX-DOS commands
OS/2 commands
ReactOS commands
Windows commands
Windows administration
IBM i Qshell commands