Making Directories with mkdir

Making directories is as easy as it sounds, although there is one parameter you should be aware of: -p. If you are in /home/paul and you want to create the directory /home/paul/audio/sound, you will get an error like this:

mkdir: cannot create directory "audio/sound": No such file or directory

At first glance this seems wrong because mkdir cannot create the directory because it does not exist. What it actually means is that it cannot create the directory sound because the directory audio does not exist. This is where the -p parameter comes in: If you try to make a directory within another directory that does not exist, like the previous, -p creates the parent directories, too. So:

mkdir -p audio/sound

That first creates the audio directory and then creates the sound directory inside it.

Was this article helpful?

0 0

Post a comment