Tag Archives: MKDIR

Creating a Linux Directory with mkdir

To create an empty directory called testdirectory within your current directory, use this command:

You can create a directory in a different location by changing what is after mkdir. To create a new directory in /home/hadi/music, if you are already in you /home directory, you can use the following:

Or from anywhere using an absolute path, you can use this:

Or from anywhere using a path shortcut, you can use the following command:

The -p option is valuable. It enables you to create a directory and its parent directories at the same time, if they do not already exist. This can be a real time saver. If the parent directories exist, the command works normally. For example, suppose you want to a new directory with two layers of subdirectories. In this example, music and testdirectory already exist, but subdir1 and subdir2 are to be created: