DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

mkdir(C)


mkdir -- make a directory

Syntax

mkdir [ -ep ] [ -m mode ] dirname ...

Description

mkdir creates the directories named in dirname. Their permissions are initially set to 777 (possibly altered by umask(C)). Creation of a directory requires write permission in the parent directory.

When a directory is created, the standard entries (for example, the files ``.'', for the directory itself, and ``..'', for its parent) are made automatically. mkdir cannot create these entries by name.

The user and group IDs of a newly created directory are set to the real user and group IDs of the creating process unless the set group ID (SGID) bit is set on the current directory (see chmod(C)). If a directory is created in a directory that has the SGID bit set, its group ID is set to that of the directory.

Directories inherit the SGID bit setting of the parent directory in which they are created.

mkdir accepts the following options:


-e
For historical compatibility, mkdir changes the ownership of the new directory to the real user ID (RUID) and the real group ID (RGID). The -e option says to use the effective user ID (EUID) and effective group ID (EGID) instead.

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

-p
With this option, mkdir creates dirname by creating all the non-existing parent directories first. Any intermediate directories that do not exist are created with mode 777 altered by umask. However, to ensure that mkdir does not fail, the user execute and write permissions are always set.

Exit values

mkdir returns 0 if all directories given in the command line were created successfully; otherwise, it prints a diagnostic and returns a non-zero value.

Diagnostics


cannot make directory: dirname
The directory dirname cannot be created.

invalid mode: mode
The permissions specified by mode are invalid.

Examples

To create newdir inside the current directory:

mkdir newdir

To create the nested directory hierarchy newdir/subdir inside the current directory, with the mode set so that only the owner has read, write and execute permissions:

mkdir -p -m700 newdir/subdir

See also

chmod(C), mkdir(S), rm(C), rmdir(C), sh(C), umask(C)

Standards conformance

mkdir is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003