The mkdir command

make directories 10 examples from the lessons of the IVski Linux Playground — try them in the terminal next to them.

Options in the examples

-p, --parents
no error if existing, make parent directories as needed, with their file modes unaffected by any -m option

Examples

mkdir projects
mkdir -p projects/website/css

Create nested directories at once

mkdir -p "$1" && cd "$1"
mkdir -p "$BACKUP_DIR"
mkdir myproject
sudo mkdir -p /var/www/shop
mkdir -p jpg && mv "$f" jpg/

Quotes keep "holiday photo.jpg" one name

mkdir -p ~/reports
mkdir /home/NAME/projects
mkdir -p /var/www/releases/v2

Lessons that use mkdir

Related commands