Create a multi-level directory in one go
To create a directory, specify the directory name as the argument of the “mkdir” command and execute it, but if you specify a directory that does not exist when specifying a directory over a multi-level hierarchy, an error will occur.
In such a case, you can force a non-existent directory to be created and create a multi-level directory at once by executing with the option “-p”.
|In the home directory of the general user nuy|
# mkdir /home/nuy/a/b/c ←Use mkdir to create a multi-level hierarchical directory
mkdir: directory `. /a/b/c’ cannot be created: no such files or directories
↑Error because you specified a non-existent directory
# mkdir -p /home/nuy//a/b/c
↑Create a multi-level directory by specifying the option “-p” for “mkdir”.。
# cd /home/nuy/a/b/c
↑A directory has been created, including one that does not exist.