With mkdir -v -p project/src/assets, each created directory gets its own line. I love how that output makes each new level visible.
Choose the directory path you want ready, either beneath your current directory or starting at the filesystem root. See what mkdir creates at that resolved location.
What mkdir creates
On a GNU Coreutils system, mkdir creates one or more directories at the paths you supply. A relative path starts from the shell’s current working directory, while a path beginning with a slash starts at the filesystem root.
| Path supplied | Where it resolves |
|---|---|
| notes | A directory named notes under the current working directory |
| ./logs/archive | A nested path under the current working directory |
| /srv/app/logs | A path that starts at the filesystem root |
The Linux mkdir manual lists the available options, and mkdir creates directory entries rather than the files you plan to put inside them.
What you need before creating a directory
Check the path from the shell’s current directory, then confirm you can write to the parent that will hold the new entry.
- For a relative path, know which directory your shell is in. mkdir does not move the shell into the new directory.
- For a plain path, each parent directory must already exist. The account running mkdir needs write and search permission on the parent, as described in the Linux mkdir system-call manual.
- For names with spaces, quote the path or a shell variable so the shell passes it as one argument.
On Linux, a directory’s execute bit lets the shell traverse its name. Creating a child also needs write access to the parent, because mkdir adds a new directory entry there.
Each slash-separated path component depends on its parent. The -p option creates missing components, but it does not override permission checks on the parent path.
Create directories by task
Use a separate operand for each directory, or add -p when the path includes missing parents. The examples stay relative to the directory where the command runs.
1. Create one or several directories
Pass one name to create one directory, or several names to create separate directories in one invocation. I ran the multiple-name form below, and each path appeared under the current working directory.
mkdir notes projects logs

The screenshot lists each directory after one mkdir command. Its root prompt is just what that capture displays, and your account can create directories anywhere it has permission to write.
Once the directory exists, you can create a file in Linux inside it, then count the files in the directory as its contents grow.
2. Build a nested path when parents are missing
I ran plain mkdir against a nested path with missing parents. It returned “No such file or directory.”
mkdir parent/child/child2/child3
mkdir -p parent/child/child2/child3

The screenshot’s final ls shows only parent, so use find to see every created level.
find parent -type d -print | sort
With -p, an existing target directory does not cause an error. It creates the missing path levels in order, but a file at the final path still blocks directory creation.
A directory that needs a new name can be handled with the Linux directory-renaming methods.
3. Show what mkdir created
By default, mkdir prints nothing after success, while -v reports each directory created.
mkdir -v -p project/src/assets

Each line names a directory created by the command. The other screenshot runs from a root prompt and creates the absolute path /parent, so choose a destination your account can write instead.

Verbose output names only directories created by this invocation, not path components that already existed.
Set a directory mode deliberately
The umask is a process setting that removes permission bits from mkdir’s default directory mode of 0777. With -m, GNU mkdir applies your requested mode to the final directory, while parents created by -p keep their own modes.
| Mode choice | Permission result |
|---|---|
| Plain mkdir under umask 0027 | The tested mode was 750 from the default directory request of 0777 |
| Explicit mode 700 | The owner has full access. Group and other users have none. |
| Explicit mode 0777 | Every user class gets full access. Use it only when that access is intended. |
I ran a plain mkdir under umask 0027, and stat reported mode 750. The mask removed group-write and other-user permissions from the default directory mode.
Mode 7 gives one user class all three permission bits. On a directory, read lists entries and execute lets you traverse a known name.
Write permission lets you add or remove names in that directory. In an octal mode, the three digits map from owner to group to other users.
When no explicit mode is supplied, the process umask removes permission bits from the requested directory mode. A default ACL on the parent changes that calculation, as the Linux umask manual explains.
The screenshot’s 0777 mode grants read, write and traverse bits to owner, group and other users, which is broader than a private directory needs.

I used -m 700 for private-data, and stat reported mode 700, leaving access to its owner.
mkdir -m 700 private-data && stat -c '%a %n' private-data

If another account needs ownership rather than only different permission bits, the chown command changes the directory owner. The mkdir operation itself assigns the new directory to the effective user and group, subject to the parent directory’s group-inheritance settings.
When mkdir refuses a path
The error usually points to a missing parent, an occupied path, or access to the parent directory. Check the path before adding privileges.
| What you see | What to check next |
|---|---|
| No such file or directory | A parent is missing. Create it first or add -p when every missing level belongs in the chosen path. |
| File exists | The target name is occupied. Choose another name, or use -p if it is already a directory. |
| Permission denied | Your account lacks write or search access on the parent. Choose a permitted directory or ask its owner for access. |
| A name with spaces becomes several names | The shell split the unquoted value before mkdir received it. Quote the path or variable. |
Creating a directory does not populate it. If it is empty and no longer needed, follow the steps to remove a directory.
A tree containing files needs a separate deletion decision. Read the rm command in Linux guidance before deleting its contents.
Build only the path you intend
Use -p when missing parent levels are part of the destination you chose. A relative path keeps the new tree beneath the current working directory.
mkdir -p project/logs/archive
Questions about mkdir
What does mkdir -p do?
The -p option creates missing parent directories and suppresses an error when the target already exists as a directory.
Can I pass a variable to mkdir?
Yes. The shell expands a variable before mkdir receives its argument, and quotes keep a value with spaces as one path.
Can I mkdir and cd in one command?
Yes. Run mkdir -p logs && cd logs. The shell runs cd only when mkdir succeeds.
Can mkdir create a directory and a file together?
Yes. Run mkdir -p draftsite && touch draftsite/README.md. The shell runs touch only when mkdir succeeds.
Before running a relative path, check the directory your shell is in.
pwd
