Command library / mkdir
mkdir
Create a new directory
Creates one or more directories. -p is the one you'll use constantly: it creates every missing parent directory in a path at once, and — unlike a bare mkdir — doesn't error if the directory already exists. -v makes it report every directory it actually creates.
Practice mkdirUsage
Options and flags
directoryone or more directory paths to create
-p, --parentscreate missing parent directories as needed; no error if it already exists
-v, --verboseprint a line for each directory created
Examples
mkdir backupsCreate a single new directory here.
mkdir -p logs/2026/09Create the whole nested path in one shot, even though logs/ and logs/2026/ don't exist yet.
mkdir reports configs scriptsCreate three directories side by side in one command.
mkdir -pv project/src/libCreate the nested path and print a line for every directory actually created.
Common mistakes
Without -p, mkdir refuses the whole thing if any parent directory in the path is missing — plain mkdir can only create the final, deepest directory.