Linux directory FAQ: How do I create (make) a directory on Linux or Unix?
mkdir command is used to create new Unix/Linux directories (sub-directories). Let's take a look at some
mkdir command examples.
This first example creates a new directory named tmp in your current directory:
This example assumes that you have the proper permissions to create a new sub-directory in your current working directory.
This command creates three new sub-directories (memos, letters, and e-mail) in the current directory:
mkdir memos letters e-mail
-p option of the
mkdir command to create multiple levels of subdirectories with one command. This example creates the directory /home/joe/customer/acme/foo/bar, and makes all intermediate subdirectories, as needed:
mkdir -p /home/joe/customer/acme/foo/bar
As you can imagine, that's a lot easier than typing these equivalent commands:
cd /home/joe mkdir customer cd customer mkdir acme cd acme mkdir foo cd foo mkdir bar
As a final note, if you try to create a directory like this:
and you get an error message like this:
mkdir: cannot create directory 'baz': Permission denied
as the message implies, you don't have permission to create this directory. You can use the ls command to figure out what permission you have in this directory.