Skip to content

Creating directories#

There's not really much to creating directories:

1
$ mkdir mydirectory

And you'll get a directory called mydirectory in the current working directory (.). You can also create a directory at another location, either relative from your current location or absolutely, somewhere else.

If I wanted to create a directory inside another directory, I could do this:

1
$ mkdir existing_directory/new_directory

Which means I'm creating a new directory called new_directory inside of existing_directory. But I can also create a new directory anywhere on the file system being using an absolute path:

1
$ mkdir /home/myusername/my_files

Which would create a directory called my_files at /home/myusername/.

Finally, if you want to create a series of directories inside of each other, without having to create them one by one, you can use the -p flag to create all the non-existent parent directories:

1
$ mkdir -p 1/2/3/4/5/6/7/8/9/

If we assume 1/ doesn't exist, then everything from 1/ onwards will be created for you.