Create Nested Directories using mkdir Command


If you use the mkdir to create a directory inside a directory you would get an error,

# mkdir dir1/dir2
mkdir: cannot create directory 'dir1/dir2': No such file or directory 

To create a nested directories like dir1/dir2 you need to pass in an optional argument -p or --parents along with it.


Example:
# mkdir -p dir1/dir2/dir3

Create nested directories using mkdir command
-


Have Questions? Post them here!

Topics Coverage:


🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.

Follow Us: GitHub | Facebook | Twitter | Instagram