mkdir - Make directories

Synopsis

mkdir [-p] [-m mode] directory ...

Description

The mkdir utility creates the directories named as operands, in the order specified, using mode rwxrwxrwx (0777) as modified by the current file creation mask.

The user must have write permission in the parent directory.

Options

-m
Set the file permission bits of the final created directory to the specified mode. The mode argument can be in any of the formats supported by the chmod command. If a symbolic mode is specified, the operation characters + and - are interpreted relative to an initial mode of "a=rwx".
-p
Create intermediate directories as required. If this option is not specified, the full path prefix of each operand must already exist. Intermediate directories are created with permission bits of rwxrwxrwx (0777) as modified by the current file creation mask, plus write and search permission for the owner.

Exit status

  • 0 if successful
  • >0 if an error occurred.
Examples
Create the directories "new", "java", "test", "dir", "4" and "bob" and set the mode to read, write and execute for owner.

mkdir -p -m 700 /new/java/test/dir/4/bob