Where to start First steps track · 15 stages
Linux Labs

mkdir — creating directories

cheat sheet · Linux · coreutils https://lab.dimsanych.ru/en/wiki/mkdir/

Cheat sheet

  • mkdir -p a/b/c a chain of directories
  • mkdir -p site/{css,js,img} several at once
  • mkdir -m 700 ~/.secrets with permissions right away
  • rmdir empty remove an empty one

Options

bash
mkdir reports                     # one directory in the current one
mkdir a b c                       # several at once
mkdir -p proj/src/api             # -p: create the WHOLE chain (proj and proj/src too)
mkdir -p logs                     # -p also doesn't fail if logs already exists (handy in scripts)
mkdir -m 700 ~/.secrets           # -m: set permissions right away (here — owner only)
mkdir -v new                      # -v: print what was created (verbose)
mkdir -p site/{css,js,img}        # bash brace expansion → site/css site/js site/img
mkdir -p data/{2024,2025}/{01,02} # combinations: data/2024/01 … data/2025/02

Main options:

Option What it does
-p, --parents create parent directories along the path; not an error if it already exists
-m, --mode=MODE set permissions right at creation time (instead of umask)
-v, --verbose print the name of every directory created
Loading…