Mkdir

Last updated
mkdir
Developer(s) Various open-source and commercial developers
Written inMS-DOS: x86 assembly language
Plan 9, ReactOS: C
TRIPOS: BCPL
Operating system Unix, Unix-like, Plan 9, Inferno, DOS, MSX-DOS, FlexOS, OS/2, Windows, ReactOS, KolibriOS
Platform Cross-platform
Type Command
License GNU coreutils: GPLv3+
MS-DOS, Plan 9: MIT
FreeDOS: GPLv2+
ReactOS: GPLv2

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.

Contents

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

The ReactOS mkdir command ReactOS-0.4.13 mkdir command 667x434.png
The ReactOS mkdir command

Normal usage is as straightforward as follows:

mkdirname_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 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-ptmpdir/{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

Related Research Articles

cd (command) Computer command in various operating systems

The cd command, also known as chdir, is a command-line shell command used to change the current working directory in various operating systems. It can be used in shell scripts and batch files.

dir (command) Directory information command on various operating systems

In computing, dir (directory) is a command in various computer operating systems used for computer file and directory listing. It is one of the basic commands to help navigate the file system. The command is usually implemented as an internal command in the command-line interpreter (shell). On some systems, a more graphical representation of the directory structure can be displayed using the tree command.

pwd Directory information command on various operating systems

In Unix-like and some other operating systems, the pwd command writes the full pathname of the current working directory to the standard output.

In computing, rmdir is a command which will remove an empty directory on various operating systems.

In computing, touch is a command used to update the access date and/or modification date of a computer file or directory. It is included in Unix and Unix-like operating systems, TSC's FLEX, Digital Research/Novell DR DOS, the AROS shell, the Microware OS-9 shell, and ReactOS. The command is also available for FreeDOS and Microsoft Windows.

In computing, echo is a command that outputs the strings that are passed to it as arguments. It is a command available in various operating system shells and typically used in shell scripts and batch files to output status text to the screen or a computer file, or as a source part of a pipeline.

exit (command) Command of many operating system command line interpreters and scripting languages

In computing, exit is a command used in many operating system command-line shells and scripting languages.

more (command) Terminal pager available on various operating systems

In computing, more is a command to view the contents of a text file one screen at a time. It is available on Unix and Unix-like systems, DOS, Digital Research FlexOS, IBM/Toshiba 4690 OS, IBM OS/2, Microsoft Windows and ReactOS. Programs of this sort are called pagers. more is a very basic pager, originally allowing only forward navigation through a file, though newer implementations do allow for limited backward movement.

In computing, sleep is a command in Unix, Unix-like and other operating systems that suspends program execution for a specified time.

tree (command) Shell command in various operating systems

In computing, tree is a recursive directory listing command or program that produces a depth-indented listing of files. Originating in PC- and MS-DOS, it is found in Digital Research FlexOS, IBM/Toshiba 4690 OS, PTS-DOS, FreeDOS, IBM OS/2, Microsoft Windows, and ReactOS. A version for Unix and Unix-like systems is also available.

<span class="mw-page-title-main">ATTRIB</span>

In computing, ATTRIB is a command in Intel ISIS-II, DOS, IBM OS/2, Microsoft Windows and ReactOS that allows the user to change various characteristics, or "attributes" of a computer file or directory. The command is also available in the EFI shell.

move (command)

In computing, move is a command in various command-line interpreters (shells) such as COMMAND.COM, cmd.exe, 4DOS/4NT, and PowerShell. It is used to move one or more files or directories from one place to another. The original file is deleted, and the new file may have the same or a different name. The command is analogous to the Unix mv command and to the OpenVOS move_file and move_dircommands.

ren (command)

In computing, ren is a command in various command-line interpreters (shells) such as COMMAND.COM, cmd.exe, 4DOS, 4NT and Windows PowerShell. It is used to rename computer files and in some implementations also directories. It is analogous to the Unix mv command. However, unlike mv, ren cannot be used to move files, as a new directory for the destination file may not be used. Alternatively, move may be used if available. On versions of MS-DOS that do not support the move command, the user would simply copy the file to a new destination, and then delete the original file. A notable exception to this rule is DOSBox, in which ren may be used to move a file, since move is not supported.

del (command) Command in various operating systems

In computing, del is a command in command-line interpreters (shells) such as COMMAND.COM, cmd.exe, 4DOS, NDOS, 4OS2, 4NT and Windows PowerShell. It is used to delete one or more files or directories from a file system.

ver (command) Command in many command-line interpreters

In computing, ver is a command in various command-line interpreters (shells) such as COMMAND.COM, cmd.exe and 4DOS/4NT. It prints the name and version of the operating system, the command shell, or in some implementations the version of other commands. It is roughly equivalent to the Unix command uname.

In some operating systems, vol is a command within the command-line interpreters (shells) such as COMMAND.COM and cmd.exe. It is used to display the volume label and volume serial number of a logical drive, such as a hard disk partition or a floppy disk, if they exist.

help (command) Command in various command line shells

In computing, help is a command in various command line shells such as COMMAND.COM, cmd.exe, Bash, qshell, 4DOS/4NT, Windows PowerShell, Singularity shell, Python, MATLAB and GNU Octave. It provides online information about available commands and the shell environment.

copy (command)

In computing, copy is a command in various operating systems. The command copies computer files from one directory to another.

<span class="mw-page-title-main">TIME (command)</span>

In computing, TIME is a command in DEC RT-11, DOS, IBM OS/2, Microsoft Windows and a number of other operating systems that is used to display and set the current system time. It is included in command-line interpreters (shells) such as COMMAND.COM, cmd.exe, 4DOS, 4OS2 and 4NT.

format (command)

In computing, format, a command-line utility that carries out disk formatting. It is a component of various operating systems, including 86-DOS, MS-DOS, IBM PC DOS and OS/2, Microsoft Windows and ReactOS.

References

  1. "Users guide" (PDF). bitsavers.org. Archived from the original (PDF) on 2019-09-25. Retrieved 2019-10-22.
  2. "JaTomes Help - OS/2 Commands". www.jatomes.com.
  3. "GitHub - reactos/reactos: A free Windows-compatible Operating System". October 22, 2019 via GitHub.
  4. "EFI Shells and Scripting". Intel . Retrieved 2013-09-25.
  5. "Reference manual" (PDF). stratadoc.stratus.com. Retrieved 2019-10-22.
  6. "Introduction to Tripos" (PDF). Retrieved 2019-10-22.
  7. Rügheimer, Hannes; Spanik, Christian (October 22, 1988). AmigaDOS quick reference. Grand Rapids, Mi : Abacus. ISBN   9781557550491 via Internet Archive.
  8. "Make new folder - MATLAB mkdir". www.mathworks.com.
  9. "Function Reference: mkdir". octave.sourceforge.io.
  10. Wolverton, Van (2003). Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition. Microsoft Press. ISBN   0-7356-1812-7.
  11. "DR DOS 6.0 User Guide Optimisation and Configuration Tips" (PDF). Archived from the original (PDF) on 2019-09-30. Retrieved 2019-08-13.
  12. "Datalight ROM-DOS User's Guide" (PDF). www.datalight.com.
  13. "mkdir(1): make directories - Linux man page". linux.die.net.
  14. "Shell - KolibriOS wiki". wiki.kolibrios.org.
  15. "Microsoft Windows XP - Mkdir". Microsoft. Archived from the original on July 22, 2016. Retrieved 25 October 2012.
  16. "Microsoft Windows XP - Cmd". Microsoft. Retrieved 25 October 2012.

Further reading