---
title: "mkdir command"
description: "The mkdir command allows you to create directories that you name. This command can create multiple directories at once or even multiple levels creating the parent directories along the way. Command:..."
url: https://www.inmotionhosting.com/support/server/linux/mkdir-command/
date: 2014-06-23
modified: 2014-06-23
author: "Scott Mitchell"
categories: ["Linux"]
type: post
lang: en
---

# mkdir command

The *mkdir* command allows you to create directories that you name. This command can create multiple directories at once or even multiple levels creating the parent directories along the way.

**Command: **mkdir
**Synopsis: **mkdir ... ...

**Options: **

| Option | Long option name | Description |
| --- | --- | --- |
| -m | --mode=MODE | Set permission mode (as in chmod), not rwxrwxrwx - umask. |
| -p | --parents | No error if existing, make parent directories as needed. |
| -v | --verbose | Print a message for each created directory. |
| -Z | --context=CONTEXT | (SELinux) set security context to CONTEXT. |

## Examples

### The Base Command

**mkidr ** - Using the base command, the mkdir will create a new directory in the current location. Below we create a new folder named testdir. # mkdir testdir # ls ./ ../ error_log index.php testdir/ test.txt

### Create multiple directories in same folder

**mkidr ** - Using the same base command, you can create more than one directory at the same time by separating them with a space. Below we create a new folder named testdir and test2. # mkdir testdir test2 # ls ./ ../ error_log index.php testdir/ test.txt test2

### Create multiple levels at once

**mkidr ** - If you are wanting to create a subdirectory tree that goes down more than one level, use the *-p* option. Here we create a subdirectory tree under testdir/level1/level2. # mkdir -p testdir/level1/level2 # pwd /home/rubelix/public_html/test/testdir/level1/level2
