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.
How to create one directory
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.
Linux mkdir example - How to create multiple directories at one time
This command creates three new sub-directories (memos, letters, and e-mail) in the current directory:
mkdir memos letters e-mail
Linux mkdir example - How to create several subdirectories at one time
-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
Linux mkdir command: "Permission denied" errors
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.
Hi, what does "touch var/.htaccess | mkdir app/etc" do?
In this case, the file .htaccess doesn't exist, so it will be created with the touch command, but then what happens when redirected to the mkdir command?
Thanks for your help!