By Alvin Alexander. Last updated: August 9, 2019
Linux mkdir
question: I'm about to go to work on a new server, and I want to create subdirectories named docs, bin, and lib, and the docs directory has two subdirectories named
personal and business. How can I create these directories and subdirectories with one command?
Answer: Use the -p
option of the Unix/Linux mkdir
command. The answer is shown below:
mkdir -p bin docs/personal docs/business lib
The -p
option of the Linux mkdir
command tells mkdir
to "create parent directories as needed" when it's told to create directories that are multiple levels deep, such as "docs/personal".