UnixDroid

Files · Linux command

mkdir command in Linux

What does mkdir do?

mkdir creates new folders (directories). With -p it creates every missing parent folder in the path and does not complain if the folder already exists.

mkdir [-p] folder…

Most useful options

OptionWhat it does
-pcreate parent folders as needed, no error if it exists
-m 700set permissions while creating

mkdir examples

$ mkdir notes Try it ›

create one folder

$ mkdir -p lab/notes/day1 Try it ›

create a whole tree at once

$ mkdir -m 700 private Try it ›

a folder only you can open

In security work

Keep one folder per project (mkdir -p project/docs project/logs) to stay organised.

Questions about mkdir

How do I create multiple folders at once?

List them: mkdir a b c, or create a nested path with mkdir -p a/b/c.