•Arnošt Havelka
Creating Directories with mkdir
Master mkdir to create single and nested directory structures.
Start Interactive LessonThe mkdir command creates directories (folders). It's the foundation of file organization.
Create a Single Directory
Use mkdir followed by a directory name to create one folder.
Try the command
Create a new directory!
Build the command
mkdir[arguments]
mkdir
Terminal
~$mkdir Projects
Create a folder:
Terminal
~$mkdir MyFolder
ls
Create Nested Directories: mkdir -p
The -p flag creates parent directories as needed. Perfect for building entire folder structures at once.
Try the command
Build nested folders!
Build the command
mkdir[arguments]
mkdir
Terminal
~$mkdir -p src/components/buttons
Build structures instantly:
Terminal
~$mkdir -p project/src/utils
ls -R
Create Multiple Directories
Create several folders at the same level with one command.
Try the command
Create multiple folders!
Build the command
mkdir[arguments]
mkdir
dir1 dir2 dir3Multiple directories - creates all of them in the current location.
Terminal
~$mkdir src docs tests
Batch directory creation:
Terminal
~$mkdir docs images videos
ls
Knowledge Check
1 / 3What does mkdir do?
References
These documentation links provide authoritative details for the commands used in this article.
Up Next
Create empty files with touch
Make a new empty file, or update the timestamp on a file that already exists.