185

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,380
  • 25
  • 108
  • 167
BaltoStar
  • 2,331
  • 3
  • 16
  • 11

2 Answers2

234

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,380
  • 25
  • 108
  • 167
55

Use the -p option. Your command should be:

sudo mkdir -p x/y/z
unxnut
  • 5,908
  • 2
  • 19
  • 27