Creating Directories

Learn how to create multiple directories and paths using a single command.

The mkdir command

While we can create files in several ways, we’ll use the mkdir command to create directories. We learned how to use this command in Creating Directories in the introduction, but let’s dig in a little deeper by performing a common task: setting up a hierarchy of directories to store documents.

Let’s create a directory by the name of files:

$ mkdir files

Then, we use the ls command to verify the new directory exists:

$ ls -l
Terminal 1
Terminal
Loading...

Creating a subdirectory

Now, let’s create a directory inside of the files directory called photos. Based on what we’ve learned so far, our first instinct might be to do this by changing the working directory to the files directory and then issuing another mkdir command, but that’s not efficient. Instead, we ...