mkdir
Files and directories
Usage
mkdir -p [path]Creates a directory; without -p it fails both when a parent is missing and when the directory already exists.
Common flags
| Flag | Meaning |
|---|---|
| -p | Create missing parents, and do not complain if it exists |
| -m | Set the mode of the new directory, as in -m 700 |
| -v | Print a line for each directory created |
Examples
mkdir -p a/b/cCreates the whole chain in one call.
mkdir -m 700 privateA directory only you may enter.
Moving, deleting and finding. Some of these do not ask twice, which is why -i becomes a habit.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does mkdir do?
Creates a directory; without -p it fails both when a parent is missing and when the directory already exists.
Q. How do I type it?
mkdir -p [path] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
3 are listed here; the full set is in man mkdir. This command sits under Files and directories.
Related commands
man page: man mkdir