Mkdir: Difference between revisions
removed false info |
imported>Susko3 m →top: Revert vandalism |
||
| Line 17: | Line 17: | ||
| license = [[GNU]] [[coreutils]]: [[GPLv3+]]<br />[[MS-DOS]], Plan 9: [[MIT License|MIT]]<br />[[FreeDOS]]: [[GPLv2+]]<br />[[ReactOS]]: [[GPLv2]] | | license = [[GNU]] [[coreutils]]: [[GPLv3+]]<br />[[MS-DOS]], Plan 9: [[MIT License|MIT]]<br />[[FreeDOS]]: [[GPLv2+]]<br />[[ReactOS]]: [[GPLv2]] | ||
}} | }} | ||
('''m'''a'''k'''e '''dir'''ectory) [[command (computing)|command]] in the [[Unix]], [[DOS]], [[Digital Research|DR]] [[FlexOS]],<ref>{{cite web |url=http://www.bitsavers.org/pdf/digitalResearch/flexos/1073-2003_FlexOS_Users_Guide_V1.3_Nov86.pdf |title=Users guide |publisher=bitsavers.org |access-date=2019-10-22 |archive-date=2019-09-25 |archive-url=https://web.archive.org/web/20190925131719/http://bitsavers.org/pdf/digitalResearch/flexos/1073-2003_FlexOS_Users_Guide_V1.3_Nov86.pdf |url-status=dead }}</ref> [[IBM]] [[OS/2]],<ref>{{cite web|url=http://www.jatomes.com/Help/Os2Cmd.php#MD|title=JaTomes Help - OS/2 Commands|website=www.jatomes.com}}</ref> [[Microsoft Windows]], and [[ReactOS]]<ref>{{cite web|url=https://github.com/reactos/reactos|title=GitHub - reactos/reactos: A free Windows-compatible Operating System|date=October 22, 2019|via=GitHub}}</ref> [[operating system]]s is used to make a new [[directory (file systems)|directory]]. It is also available in the [[Unified Extensible Firmware Interface|EFI shell]]<ref name="EFI-Shells-and-Scripting">{{cite web | The '''<code>mkdir</code>''' ('''m'''a'''k'''e '''dir'''ectory) [[command (computing)|command]] in the [[Unix]], [[DOS]], [[Digital Research|DR]] [[FlexOS]],<ref>{{cite web |url=http://www.bitsavers.org/pdf/digitalResearch/flexos/1073-2003_FlexOS_Users_Guide_V1.3_Nov86.pdf |title=Users guide |publisher=bitsavers.org |access-date=2019-10-22 |archive-date=2019-09-25 |archive-url=https://web.archive.org/web/20190925131719/http://bitsavers.org/pdf/digitalResearch/flexos/1073-2003_FlexOS_Users_Guide_V1.3_Nov86.pdf |url-status=dead }}</ref> [[IBM]] [[OS/2]],<ref>{{cite web|url=http://www.jatomes.com/Help/Os2Cmd.php#MD|title=JaTomes Help - OS/2 Commands|website=www.jatomes.com|access-date=2019-07-23|archive-date=2019-04-14|archive-url=https://web.archive.org/web/20190414130029/http://www.jatomes.com/Help/Os2Cmd.php#MD|url-status=dead}}</ref> [[Microsoft Windows]], and [[ReactOS]]<ref>{{cite web|url=https://github.com/reactos/reactos|title=GitHub - reactos/reactos: A free Windows-compatible Operating System|date=October 22, 2019|via=GitHub}}</ref> [[operating system]]s is used to make a new [[directory (file systems)|directory]]. It is also available in the [[Unified Extensible Firmware Interface|EFI shell]]<ref name="EFI-Shells-and-Scripting">{{cite web | ||
| url = http://software.intel.com/en-us/articles/efi-shells-and-scripting/ | | url = http://software.intel.com/en-us/articles/efi-shells-and-scripting/ | ||
| title = EFI Shells and Scripting | | title = EFI Shells and Scripting | ||
Latest revision as of 16:43, 9 October 2025
Template:Short description
Template:Lowercase
Script error: No such module "Infobox".Template:Template other Script error: No such module "Check for unknown parameters".Script error: No such module "Check for conflicting parameters".
The mkdir (make directory) command in the Unix, DOS, DR FlexOS,[1] IBM OS/2,[2] Microsoft Windows, and ReactOS[3] operating systems is used to make a new directory. It is also available in the EFI shell[4] 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 create_dir command.[5] MetaComCo TRIPOS and AmigaDOS provide a similar MakeDir command to create new directories.[6][7] The numerical computing environments MATLAB and GNU Octave include an mkdir
function with similar functionality.[8][9]
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 and linked in the . and .. directory entries manually. The command is available in MS-DOS versions 2 and later.[10] Digital Research DR DOS 6.0[11] and Datalight ROM-DOS[12] also include an implementation of the md and mkdir commands.
The version of mkdir bundled in GNU coreutils was written by David MacKenzie.[13]
It is also available in the open source MS-DOS emulator DOSBox and in KolibriOS.[14]
Usage
mkdir commandNormal 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,[15] the default[16]), 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/bwill create directoryaif it doesn't exist, then will create directorybinside directorya. If the given directory already exists, ignore the error.-m (--mode): mode, specify the octal permissions of directories created bymkdir.
-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 extension, nothing mkdir does itself):
mkdir -p tmpdir/{trunk/sources/{includes,docs},branches,tags}
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/{trunk/sources/{${DOMAIN_NAME}},branches,tags}"
This will create:
tmpdir
________|______
| | |
branches tags trunk
|
sources
____|_____
| |
includes docs
See also
- Filesystem Hierarchy Standard
- 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
<templatestyles src="Reflist/styles.css" />
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
Script error: No such module "Check for unknown parameters".
Further reading
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
External links
Template:Sister project Template:Sister project
- Microsoft TechNet Mkdir article
- : make directories – Shell and Utilities Reference, The Single UNIX Specification, Version 5 from The Open Group
- – Plan 9 Programmer's Manual, Volume 1
- – Template:Man/Inferno
Script error: No such module "Navbox". Template:Plan 9 commands Template:Core Utilities commands Script error: No such module "Navbox".