Back to the command reference

mkdir

FilesBeginner In simulator In real Linux

Make directories

Name: mkdir = make directory

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

mkdir creates one or more directories. By default the parent must already exist and the target must not.

-p creates any missing parents and doesn't complain if the directory already exists, which makes it script-friendly. -m sets the permissions at creation time.

Syntax

mkdir [OPTION]... DIRECTORY...

Common options

-p / --parentsCreate parent directories as needed; no error if it exists
-v / --verbosePrint a message for each created directory
-m / --mode MODESet permissions at creation, e.g. -m 700

Examples

  • $ mkdir backup

    Create one directory

    Explain
  • $ mkdir -p projects/api/src

    Create nested directories in one go

    Explain

Related