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.

# mkdir -p dir1/dir2/dir3

Create nested directories using mkdir command

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap