HxHippy

mkdir

Make directories

Overview

The mkdir command is used to create one or more new directories. If the specified directory does not exist, mkdir creates it.

Syntax

mkdir [OPTION]... DIRECTORY...

Common Options

-m, --mode=MODE

Set file mode (as in chmod), not a=rwx - umask.

-p, --parents

No error if existing, make parent directories as needed.

-v, --verbose

Print a message for each created directory.

-Z

Set SELinux security context of each created directory to default type.

--context[=CTX]

Like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX.

Examples

$ mkdir new_directory

Create a directory named new_directory in the current location.

$ mkdir -p project/src/components

Create the full directory path project/src/components, including any non-existent parent directories (project and src).

$ mkdir dir1 dir2 dir3

Create three directories: dir1, dir2, and dir3.

$ mkdir -m 700 private_stuff

Create a directory named private_stuff and set its permissions to rwx------ (only owner has read, write, execute).

$ mkdir -v logs reports config

Create directories logs, reports, and config, and print a message for each one created.

makedirectoryfoldercreatemkdir