Hi Guys! Today we will look at one of the popular Linux command mkdir with examples and options, the mkdir is basically used to create a directory and the folder in Linux OS.
$ mkdir tastethelinux
Our first command will create the directory named as tastethelinux.
Structure: mkdir [options] [folder/directory]
This is a syntax to write the command in BASH/TERMINAL.
Let’s have an example and then we will move forward,
$ mkdir -p taste/the/linux
So, mkdir is the command, -p is an option and taste/the/linux is an argument.
Kindly refer the link so you can practice with us while learning the POST, it will take 40 to 50 seconds to boot the image.
Now we have look the another option with the same commands, just try “mkdir example/tastethelinux/aa/bb“

Error: mkdir: cannot create directory ‘example/tastethelinux/aa/bb’: No such file or directory
So we will use the first option -p of the mkdir command for the above Solution.
- mkdir option -p is used to create a parent directory
$ mkdir -p example/tastethelinux/aa/bb
So the question was, what is the parent directory now example/tastethelinux/aa/bb, you can see bb it’s parent directory is aa, and the parent directory of aa is tastethelinux and the parent directory of tastethelinux is an example.
- mkdir option -v is a verbose this will print the message
$ mkdir -v tastethelinux output: mkdir:created directory 'tastethelinux'
- mkdir option -m is used when we have to set the permission of the directory.
$ mkdir -m 777 tla
In the above example, we have set the permission as 777. So, when we will create the directory by default value is 775.
Cheat-sheet of mkdir command
1. To Create a directory Syntax: mkdir [directory_name] Example: mkdir tastethelinux
2. To create a Multiple directory Syntax: mkdir [directory_name] [directory1_name] [directory3_name] Example: mkdir taste the linux
3. To create a Multiple directories with {} Syntax: mkdir {[directory_name],[directory1_name],[directory3_name]} Example: mkdir {taste,example,linux}
4. Create a parent directory Syntax: mkdir -p [directory_name]/[directory1_name]/[directory3_name] Example: mkdir -p taste/exam/pratice
5. Print the message while creating a directory Syntax: mkdir -v [directory_name] Example: mkdir -v taste
6. set permission while creating a directory Syntax: mkdir -m [permission] [directory_name] Example: mkdir -m 770 tastethelinux
So, Lets try to Solve some Questions for mkdir command

[wp_quiz id=”1030″]
Let’s see the chart Solution Number 4
practice ├── aa │ ├── a1 │ └── a2
$ mkdir -vp practice/aa/a{1..2} output: mkdir: created directory 'practice' mkdir: created directory 'practice/aa' mkdir: created directory 'practice/aa/a1' mkdir: created directory 'practice/aa/a2'
├── bb │ ├── b1 │ ├── b2 │ ├── b3 │ ├── b4 │ └── b5
$ mkdir -pv practice/bb/b{1..5} output: mkdir: created directory 'practice/bb' mkdir: created directory 'practice/bb/b1' mkdir: created directory 'practice/bb/b2' mkdir: created directory 'practice/bb/b3' mkdir: created directory 'practice/bb/b4' mkdir: created directory 'practice/bb/b5'
└── cc
$ mkdir -v practice/cc output: mkdir: created directory 'practice/cc'
$ mkdir -vp practice/{aa/a{1..2},bb/b{1..5},cc} output: mkdir: created directory 'practice' mkdir: created directory 'practice/aa' mkdir: created directory 'practice/aa/a1' mkdir: created directory 'practice/aa/a2' mkdir: created directory 'practice/bb' mkdir: created directory 'practice/bb/b1' mkdir: created directory 'practice/bb/b2' mkdir: created directory 'practice/bb/b3' mkdir: created directory 'practice/bb/b4' mkdir: created directory 'practice/bb/b5' mkdir: created directory 'practice/cc'
You can also create a same directory via using this command
$ mkdir -vp practice/aa/a{1..2} practice/bb/b{1..5} practice/cc
To Learn more basic commands refer to the link and learn more of the basic commands. Thanks to read the POST. Keep Supporting us!
Thanks! i learnt more options in make directories. it makes me easy to create multiple directories.
Hi
Good and very useful information about mkdir command. Every option is explained well and easy to understand.
Thanks Venkat