HOME

TheInfoList



OR:

The mkdir (make directory) command in the Unix, DOS, DR FlexOS, IBM OS/2,
Microsoft Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
, and
ReactOS ReactOS is a free and open-source operating system for amd64/i686 personal computers intended to be binary-compatible with computer programs and device drivers made for Windows Server 2003 and later versions of Windows. ReactOS has been noted a ...
operating systems is used to make a new directory. It is also available in the EFI shell and in the PHP scripting language. In DOS, OS/2, Windows and ReactOS, the command is often abbreviated to md. The command is analogous to the Stratus
OpenVOS Stratus VOS (Virtual Operating System) is a proprietary operating system running on Stratus Technologies fault-tolerant computer systems. VOS is available on Stratus's ftServer and Continuum platforms. VOS customers use it to support high-volume ...
create_dir command. MetaComCo TRIPOS and
AmigaDOS AmigaDOS is the disk operating system of the AmigaOS, which includes file systems, file and directory manipulation, the command-line interface, and file Redirection (computing), redirection. In AmigaOS 1.x, AmigaDOS is based on a TRIPOS port by ...
provide a similar MakeDir command to create new directories. The numerical computing environments MATLAB and GNU Octave include an mkdir function with similar functionality.


History

In early versions of Unix ( 4.1BSD and early versions of System V), this command had to be setuid root as the kernel did not have an mkdir syscall. Instead, it made the directory with
mknod In Unix-like operating systems, a device file or special file is an interface to a device driver that appears in a file system as if it were an ordinary file. There are also special files in DOS, OS/2, and Windows. These special files allow an ...
and linked in the . and .. directory entries manually. The command is available in MS-DOS versions 2 and later. Digital Research DR DOS 6.0 and Datalight ROM-DOS also include an implementation of the and commands. The version of mkdir bundled in GNU coreutils was written by David MacKenzie. It is also available in the
open source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
MS-DOS emulator DOSBox and in KolibriOS.


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 script A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manip ...
s.


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 extension, nothing mkdir does itself): mkdir -p tmpdir/ If one is using variables with mkdir in a bash script, POSIX `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 The Filesystem Hierarchy Standard (FHS) is a reference describing the conventions used for the layout of a UNIX system. It has been made popular by its use in Linux distributions, but it is used by other UNIX variants as well. It is maintained b ...
* GNU Core Utilities * Find – The find command coupled with mkdir can be used to only recreate a directory structure (without files). * List of Unix commands * List of DOS commands


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