189

Apparently, it's not possible to create a nested directory in a single command?

$ sudo mkdir x/y/z
mkdir: cannot create directory 'x/y/z': No such file or directory
Braiam
  • 35,991
BaltoStar
  • 2,371

2 Answers2

239

The command you are looking for is mkdir -p x/y/z. The -p switch create parents directories.

~$ mkdir -p d/s/a/e
~$ cd d/s/a/e/
~/d/s/a/e$ 
Braiam
  • 35,991
57

Use the -p option. Your command should be:

sudo mkdir -p x/y/z
unxnut
  • 6,008