Forever & AlwaysLINUX COMMAND ATLAS

LINUX COMMAND ATLAS · COMMAND GUIDE

Linux mkdir command

Create a directory. The -p flag also creates missing parent directories.

GNU Coreutils

Syntax

Command form
mkdir [OPTION]... DIRECTORY...

Common options

4 options
OptionWhat it does
-p, --parentsCreate missing parent directories; do not fail if they exist.
-m, --mode=MODESet permissions using a symbolic or numeric mode.
-v, --verbosePrint a message for each created directory.
-ZSet the SELinux security context on created directories.

Usage examples

3 examples

Create a directory. The -p flag also creates missing parent directories.

mkdir -p ./project/logs

Create a directory tree, including missing parents.

mkdir -p ~/projects/demo/src

Create a directory with mode 750.

mkdir -m 750 private-data

Notes

Default directory permissions can be affected by the process umask; review the result with stat or ls -ld.