xref: /titanic_44/usr/src/man/man1/mkdir.1 (revision 7014882c6a3672fd0e5d60200af8643ae53c5928)
te
Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
Copyright 1989 AT&T
Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
http://www.opengroup.org/bookstore/.
The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
This notice shall appear on any product containing this material.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
MKDIR 1 "Nov 2, 2007"
NAME
mkdir - make directories
SYNOPSIS

/usr/bin/mkdir [-m mode] [-p] dir...
"ksh93"

mkdir [-p] [-m mode] dir...
DESCRIPTION

The mkdir command creates the named directories in mode 777 (possibly altered by the file mode creation mask umask(1)).

Standard entries in a directory (for instance, the files ".", for the directory itself, and ".\|.", for its parent) are made automatically. mkdir cannot create these entries by name. Creation of a directory requires write permission in the parent directory.

The owner-ID and group-ID of the new directories are set to the process's effective user-ID and group-ID, respectively. mkdir calls the mkdir(2) system call.

"setgid and mkdir"

To change the setgid bit on a newly created directory, you must use chmod g+s or chmod g-s after executing mkdir.

The setgid bit setting is inherited from the parent directory.

"ksh93"

The mkdir built-in in ksh93 is associated with the /bin and /usr/bin paths. It is invoked when mkdir is executed without a pathname prefix and the pathname search finds a /bin/mkdir or /usr/bin/mkdir executable. mkdir creates one or more directories. By default, the mode of created directories is a=rwx minus the bits set in umask(1).

OPTIONS

The following options are supported by /usr/bin/mkdir: -m mode

This option allows users to specify the mode to be used for new directories. Choices for modes can be found in chmod(1).

-p

With this option, mkdir creates dir by creating all the non-existing parent directories first. The mode given to intermediate directories is the difference between 777 and the bits set in the file mode creation mask. The difference, however, must be at least 300 (write and execute permission for the user).

"ksh93"

The following options are supported by the mkdir built-in in ksh93: -m mode

--mode=mode

Set the mode of created directories to mode. mode is symbolic or octal mode as in chmod(1). Relative modes assume an initial mode of a=rwx.

-p

--parents

Create any missing intermediate pathname components. For each dir operand that does not name an existing directory, effects equivalent to those caused by the following command shall occur:

mkdir -p -m $(umask -S),u+wx \e
 $(dirname dir) && mkdir [-m mode] dir
Where the -m mode option represents that option supplied to the original invocation of mkdir, if any. Each dir operand that names an existing directory is ignored without error.
OPERANDS

The following operand is supported: dir

A path name of a directory to be created.

USAGE

See largefile(5) for the description of the behavior of mkdir when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).

EXAMPLES

Example 1 Using mkdir

The following example:

example% mkdir -p ltr/jd/jan

creates the subdirectory structure ltr/jd/jan.

ENVIRONMENT VARIABLES

See environ(5) for descriptions of the following environment variables that affect the execution of mkdir: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH.

EXIT STATUS

The following exit values are returned: 0

All the specified directories were created successfully or the -p option was specified and all the specified directories now exist.

>0

An error occurred.

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
CSI Enabled
Interface Stability Committed
Standard See standards(5).
"ksh93"
ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability See below.
Standard See standards(5).

The ksh93 built-in binding to /bin and /usr/bin is Volatile. The built-in interfaces are Uncommitted.

SEE ALSO

chmod(1), ksh93(1), rm(1), sh(1), umask(1), Intro(2), mkdir(2), attributes(5), environ(5), largefile(5), standards(5)