mkdir Command in Linux: Create Directories

The mkdir command creates new directories (folders) in Linux from the command line. You will use it whenever you need to set up a project layout, organize files, or prepare paths for scripts and configuration.
This guide covers how to use mkdir to create single and multiple directories, build nested directory trees, and set permissions at creation time.
Linux mkdir Command Syntax
The syntax for the mkdir command is as follows:
mkdir [OPTION] DIRECTORY...The command takes one or more directory names as its arguments.
How to Create a New Directory
To create a directory in Linux, pass the directory’s name as the argument to the mkdir command. For example, to create a new directory newdir, you would run the following command:
mkdir newdirYou can verify that the directory was created by listing the contents using the ls command
:
ls -ldrwxrwxr-x 2 username username 4096 Jan 20 03:39 newdirWhen you provide only the directory name, without the full path, it is created in the current working directory.
The current working directory
is the directory from which you are running the commands. To change the current working directory, use the cd
command.
To create a new directory in another location, provide the absolute or relative path to the parent directory. For example, to create a new directory in the /tmp directory, you would type:
mkdir /tmp/newdirIf you try to create a directory in a parent directory where the user does not have sufficient permissions, you will receive a Permission denied error:
mkdir /root/newdirmkdir: cannot create directory '/root/newdir': Permission deniedThe -v (--verbose) option tells mkdir to print a message for each created directory:
mkdir -v newdirmkdir: created directory 'newdir'How to Create Parent Directories
A parent directory is a directory that is above another directory in the directory tree. To create parent directories, use the -p option.
Suppose you want to create a directory /home/linuxize/Music/Rock/Gothic:
mkdir /home/linuxize/Music/Rock/GothicIf any of the parent directories do not exist, you will get an error:
mkdir: cannot create directory '/home/linuxize/Music/Rock/Gothic': No such file or directoryInstead of creating the missing parent directories one by one, invoke the mkdir command with the -p option:
mkdir -p /home/linuxize/Music/Rock/GothicWhen the -p option is used, the command creates the directory only if it does not already exist.
If you try to create a directory that already exists
and the -p option is not provided, mkdir will print File exists error:
mkdir newdirmkdir: cannot create directory 'newdir': File existsHow to Set Permissions when Creating a Directory
To create a directory with specific permissions, invoke the mkdir command with the -m (--mode) option. The syntax for assigning permissions is the same as with the chmod
command.
In the following example, we are creating a new directory with 700 permissions, which means that only the user who created the directory will be able to access it:
mkdir -m 700 newdirWhen the -m option is not used, the newly created directories usually have either 775 or 755 permissions, depending on the umask
value.
How to Create Multiple Directories
To create multiple directories, specify the directories’ names as the command arguments, separated by spaces:
mkdir dir1 dir2 dir3The mkdir command also allows you to create a complex directory tree with one command:
mkdir -p Music/{Jazz/Blues,Folk,Disco,Rock/{Gothic,Punk,Progressive},Classical/Baroque/Early}The command above creates the following directory tree:
Music/
|-- Classical
| `-- Baroque
| `-- Early
|-- Disco
|-- Folk
|-- Jazz
| `-- Blues
`-- Rock
|-- Gothic
|-- Progressive
`-- PunkDirectory Names with Spaces
If the directory name contains spaces or special characters, you need to either quote the name or escape the spaces with a backslash:
mkdir "My Documents"Or using backslash:
mkdir My\ DocumentsBoth commands create a directory named My Documents.
Create a Directory with a Date or Time Stamp
You can use command substitution to create a directory with the current date or time:
mkdir "backup-$(date +%F)"For example, this creates a directory like backup-2026-01-24.
How to Remove Directories
To remove an empty directory, use the rmdir command:
rmdir dirnameIf the directory is not empty, use the rm command
with the -r option to remove it recursively:
rm -r dirnameQuick Reference
| Command | Description |
|---|---|
mkdir dirname | Create a single directory |
mkdir dir1 dir2 dir3 | Create multiple directories |
mkdir -p path/to/dir | Create nested directories |
mkdir -m 755 dirname | Create with specific permissions |
mkdir -v dirname | Create and show confirmation |
FAQ
What is the difference between mkdir and touch?mkdir creates directories. The touch command
creates empty files or updates the timestamp of existing files. They serve different purposes and are not interchangeable.
What does mkdir -p do?
The -p option creates the entire directory path, including any missing parent directories. Without -p, mkdir fails if a parent directory in the path does not exist. With -p, it also silently succeeds if the target directory already exists.
Is there a difference between a folder and a directory?
No. “Folder” and “directory” mean the same thing. “Folder” is more common in desktop environments and graphical file managers, while “directory” is the standard term in the command line and Linux documentation.
Conclusion
The mkdir command handles everything from creating a single directory to building complex directory trees with brace expansion. For related file operations, see the guides on removing directories
, copying files with cp
, and listing files with ls
.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page