files
mkdir
Creates one or more directories. Can create nested paths and set the mode of new directories in a single call.
mkdir [OPTION]... DIRECTORY... Common flags
| Flag | Purpose |
|---|---|
| -p | Create parent directories as needed; do not error if they exist |
| -m | Set mode (permissions) on new directories |
| -v | Print a message for each directory created |
Examples
mkdir project Create a single directory in the cwd
mkdir -p src/app/api/users Create a nested path without failing on existing parents
mkdir -m 700 secrets Create a directory readable only by its owner
mkdir -pv logs/{app,nginx,db} Create multiple sibling directories at once via brace expansion
Gotcha
Brace expansion (logs/{a,b}) is a shell feature, not part of mkdir itself; it will not work if the shell is set to disable it.
Related commands
ln
Creates hard or symbolic links between files. Symbolic links point to a path; hard links share the same inode.
rm
Removes files and, with -r, directory trees. Deletions are immediate and not recoverable from the shell.
chmod
Changes file mode (permission bits). Accepts symbolic modes like u+x or octal modes like 755.
ls
Lists directory contents including files and subdirectories. Supports detailed views, sorting, and filtering to inspect the filesystem quickly.
cp
Copies files and directories from one location to another. Preserves or transforms metadata depending on flags.