1.\" $OpenBSD: mkdir.1,v 1.20 2004/12/13 16:02:40 jmc Exp $ 2.\" $NetBSD: mkdir.1,v 1.9 1995/07/25 19:37:13 jtc Exp $ 3.\" 4.\" Copyright (c) 1989, 1990, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" This code is derived from software contributed to Berkeley by 8.\" the Institute of Electrical and Electronics Engineers, Inc. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 3. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)mkdir.1 8.2 (Berkeley) 1/25/94 35.\" 36.Dd January 25, 1994 37.Dt MKDIR 1 38.Os 39.Sh NAME 40.Nm mkdir 41.Nd make directories 42.Sh SYNOPSIS 43.Nm mkdir 44.Op Fl p 45.Op Fl m Ar mode 46.Ar directory_name Op Ar ... 47.Sh DESCRIPTION 48The 49.Nm 50utility creates the directories named as operands, in the order specified, 51using mode 52.Li rwxrwxrwx (\&0777) 53as modified by the current 54.Xr umask 2 . 55.Pp 56The options are as follows: 57.Bl -tag -width Ds 58.It Fl m Ar mode 59Set the file permission bits of the final created directory to 60the specified 61.Ar mode . 62The mode argument can be in any of the formats specified to the 63.Xr chmod 1 64utility. 65If a symbolic mode is specified, the operators 66.Ql + 67and 68.Ql - 69are interpreted relative to an initial mode of 70.Dq a=rwx . 71.It Fl p 72Create intermediate directories as required. 73If this option is not specified, the full path prefix of each 74operand must already exist. 75Intermediate directories are created with permission bits of 76.Li rwxrwxrwx (\&0777) 77as modified by the current umask, plus write and search 78permission for the owner. 79Do not consider it an error if the 80argument directory already exists. 81.El 82.Pp 83The user must have write permission in the parent directory. 84For an explanation of the directory hierarchy, 85see 86.Xr hier 7 . 87.Pp 88The 89.Nm 90utility exits 0 on success or >0 if an error occurred. 91.Sh EXAMPLES 92Create a directory named 93.Pa foobar : 94.Pp 95.Dl $ mkdir foobar 96.Pp 97Create a directory named 98.Pa foobar 99and set its file mode to 700: 100.Pp 101.Dl $ mkdir -m 700 foobar 102.Pp 103Create a directory named 104.Pa cow/horse/monkey , 105creating any non-existent intermediate directories as necessary: 106.Pp 107.Dl $ mkdir -p cow/horse/monkey 108.Sh SEE ALSO 109.Xr chmod 1 , 110.Xr rmdir 1 , 111.Xr umask 2 , 112.Xr hier 7 113.Sh STANDARDS 114The 115.Nm 116utility is expected to be 117.St -p1003.2 118compatible. 119.Sh HISTORY 120A 121.Nm 122command appeared in 123.At v1 . 124