mkdir Command - Create Directories

You can create a directory using the mkdir command. mkdir comes from "make directory".

mkdir DirectoryName

This is a sample to create a foo directory using the mkdir command.

mkdir foo

Create a multi-level directory - "-p" option of "mkdir"

To create multiple levels of directories at once, use the "-p" option of "mkdir".

mkdir -p foo/bar

A directory called "foo / bar" will be created. If the "foo" directory does not exist, the "foo" directory is automatically created.

Show help --help option

Use the "--help" option to get help.

mkdir --help

Help is displayed.

Usage: mkdir [OPTION] DIRECTORY ...
Create the DIRECTORY (ies), if they do not already exist.

Mandatory arguments to long options are mandatory for short options too.
  -m, --mode = MODE set permission mode (as in chmod), not rwxrwxrwx --umask
  -p, --parents no error if existing, make parent directories as needed
  -v, --verbose print a message for each created directory
  -Z, --context = CONTEXT (SELinux) set security context to CONTEXT
      --help display this help and exit
      --version output version information and exit

Associated Information