| advertise add site services publishers database health videos | ![]() | about toolbar stats live show health store more stuff JOIN/LOGIN |
The mkdir (make directory) command in the Unix, DOS, OS/2 and Microsoft Windows operating systems is used to make a new directory. In DOS, OS/2 and Windows the command is often abbreviated to md.
[edit] UsageNormal 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 (ie. normal usage), the new directory would be created within the current directory. On Unix, multiple directories can be specified, and mkdir will try to create all of them. [edit] OptionsOn Unix-like operating systems, mkdir takes options. Three of the most common 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. [edit] ExamplesAn 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} This will create: tmpdir ________|______ | | | branches tags trunk | sources ____|_____ | | includes docs [edit] HistoryIn early versions of Unix (4.1BSD, 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. [edit] See also
[edit] References
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ↑ top of page ↑ | about thumbshots |