Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Use mkdir in an Ubuntu terminal to create directories. For example, mkdir projects creates a directory named projects in your current working directory, provided you can write to its parent. Add -p to create missing parent directories, -m to request permissions, or -v to see what was created.

What does the mkdir command do?

mkdir means “make directory.” It creates directories, not regular files. Its basic syntax is:

mkdir [OPTION]... DIRECTORY...

For example, mkdir reports creates a directory called reports. By contrast, touch reports creates an empty regular file. Ubuntu’s GNU mkdir options and syntax are documented in the Ubuntu mkdir(1) manual.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a directory in the current location

Relative paths are interpreted from the shell’s current working directory. Check that location first if you are unsure:

#1 Best Overall
Sale
Redragon Mechanical Gaming Keyboard Wired, 11 Programmable Backlit Modes, Hot-Swappable Red Switch, Anti-Ghosting, Double-Shot PBT Keycaps, Light Up Keyboard for PC Mac
  • Brilliant Color Illumination- With 11 unique backlights, choose the perfect ambiance for any mood. Adjust light speed and brightness among 5 levels for a comfortable environment, day or night. The double injection ABS keycaps ensure clear backlight and precise typing. From late-night tasks to immersive gaming, our mechanical keyboard enhances every experience
  • Support Macro Editing: The K671 Mechanical Gaming Keyboard can be macro editing, you can remap the keys function, set shortcuts, or combine multiple key functions in one key to get more efficient work and gaming. The LED Backlit Effects also can be adjusted by the software(note: the color can not be changed)
  • Hot-swappable Linear Red Switch- Our K671 gaming keyboard features red switch, which requires less force to press down and the keys feel smoother and easier to use. It's best for rpgs and mmo, imo games. You will get 4 spare switches and two red keycaps to exchange the key switch when it does not work.
  • Full keys Anti-ghosting- All keys can work simultaneously, easily complete any combining functions without conflicting keys. 12 multimedia key shortcuts allow you to quickly access to calculator/media/volume control/email
  • Professional After-Sales Service- We provide every Redragon customer with 24-Month Warranty , Please feel free to contact us when you meet any problem. We will spare no effort to provide the best service to every customer
pwd
mkdir project
ls -ld project

A successful mkdir normally prints nothing. The final command checks that project exists and shows its directory details.

To create several directories in the current location, give each name as a separate argument:

mkdir photos music documents

Each operand is handled separately; if an operand cannot be created, mkdir reports an error for it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create nested directories with -p

Without -p, this command fails if project or project/src does not already exist:

mkdir project/src/components

The usual error is No such file or directory. Use -p to create missing parent directories along the path:

mkdir -p project/src/components
project/
└── src/
    └── components/

-p also avoids an error if the target is already a directory, which is useful when a setup command may be run more than once. It does not make every path mistake harmless: an unintended but valid path can still be created. POSIX describes the option as creating missing intermediate pathname components and tolerating an existing target directory in its mkdir(1posix) manual.

Examples with a home-directory path and a path containing spaces:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
RisoPhy Mechanical Gaming Keyboard, RGB 104 Keys Ultra-Slim LED Backlit USB Wired Keyboard with Blue Switch, Durable Abs Keycaps/Anti-Ghosting/Spill-Resistant Computer Keyboard for PC Mac Xbox Gamer
  • 【Mechanical Keyboard: Responsive BLue Switches】RisoPhy PC keyboard features clicky keys which offer you higher accuracy and quicker response with an enjoyable click sound when typing.This keyboard is more comfortable to type on since it features deeper key travel,greater feedback,and more space between keys.For those who prefer keyboards with a more tactile and "clicky" feel,our keyboard with BLUE switches is a nice choice.
  • 【Rainbow Backlit Keyboard: illuminate Your Desktop】With 9 different backlights,5 levels of light speed and brightness,this computer keyboard enriches your gaming experience and improves your mood greatly,which is a great addition to your desktop,especially in the dark.Plus,the ultra-durable double injection ABS engineered keycaps provide crystal clear uniform backlight and greatly improve your typing accuracy at night.
  • 【High-end 104 Keys Full-Size Keyboard】The Win lock function frees your worry about mistyping when gaming(Fn+Win).Keycaps are pluggable and easy to clean,saving you much unnecessary trouble.We designed 4 hydrophobic holes for this keyboard,allowing water to flow away quickly to prevent damage to the keyboard.No longer afraid of accidents.(✦Include a keycaps puller for cleaning or other needs.)
  • 【Advanced Ergonomic Comfort】This PC gamer Keyboard adopts a scientific stair-up keycap design that keeps your arms in the most natural state to minimize hand fatigue for long time use.In order to improve your posture and make you more comfortable during use,the wired keyboard comes with 2 strong foldable rear kickstands to slope it.Moreover,the keyboard is non-slip enough because there are 4 rubber padding underneath the keyboard.
  • 【100% Anti-Ghosting & 12 Multimedia Combinations】100% anti-ghosting gaming keyboard allows all keys to work simultaneously,no matter how fast you type.12 multimedia key shortcuts allow you to quickly access to calculator/media/volume control/email.RisoPhy mechanical gaming keyboard with the number pad greatly improves your productivity.This ultra-durable keyboard with up to 50 million keystrokes life works well with Windows 7/8/10/XP/VISTA/95/98/XP/2000/ME/VISTA and Mac OS Xbox etc.
mkdir -p ~/Projects/demo
mkdir -p backups/2026/august
mkdir -p "$HOME/Documents/Work Files"

Create several related directories at once

In shells that support brace expansion, you can write:

mkdir -p project/{src,tests,docs}

The shell expands the braces before running mkdir, effectively passing these paths as separate arguments:

mkdir -p project/src project/tests project/docs
project/
├── docs/
├── src/
└── tests/

Brace expansion is a shell feature, not a mkdir option. Use the explicit command when writing scripts for shells where brace expansion may not be available.

Choose between mkdir and mkdir -p

Use When it fits What to watch for
mkdir name The parent should already exist, and an existing target should be treated as a possible mistake. Fails if the target exists or a parent component is missing.
mkdir -p path/to/name Missing parents should be created, or a setup command should be repeatable. An existing directory is accepted, so a misspelled path can go unnoticed.

Set directory permissions with -m

Use -m (or --mode) to request an initial permission mode when creating a directory:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mkdir -m 750 private

In numeric mode 750, the owner gets read, write, and execute permissions; the group gets read and execute; others get none. On a directory, execute permission means permission to search or traverse it—such as entering it or accessing items through its path—not to run the directory as a program.

A symbolic mode can make the permission classes more explicit:

mkdir -m u=rwx,g=rx,o= private

The requested mode is not necessarily the final mode. The process umask can remove requested permissions, and a default ACL may also affect the result. Linux documents the effective mode, absent a default ACL, as mode & ~umask & 0777 in the Ubuntu mkdir(2) manual. Check the actual result when access matters:

Rank #3
Redragon K521 Upgrade Rainbow LED Gaming Keyboard, 104 Keys Wired Mechanical Feeling Keyboard with Multimedia Keys, One-Touch Backlit, Anti-Ghosting, Compatible with PC, Mac, PS4/5, Xbox
  • 【Dreamy Rainbow Gaming Keyboard】K521 Gaming Keyboard Adopts a Different LED Backlight Design, Upgraded on the Traditional LED Backlight Effect, Making the Light More Penetrating, Giving You a More Dazzling Visual Effect, Making Your Gaming Process More Enjoyable
  • 【One Touch Opens & Visual Feast】The K521 Red Dragon Keyboard has a One-Touch on/off Lighting Button for Added Convenience. It also has a Three-Position Adjustable Breathing Mode and a Four-Position Adjustable Brightness Lighting Mode
  • 【Mechanical Feeling & Fast Tapping】The PC Keyboard Keys are Designed for Mechanical Feeling, Giving You a Better Feel During Use and the Ability to Trigger Keys Quickly, Allowing You to Win All Your Games
  • 【19 Keys Anti-Ghosting Keyboard】Anti-Ghosting Ensures Every Button Can Be Triggered. This Allows You to Trigger Key Combinations In The Game Accurately, And Each Skill Can Be Accurately Released to Increase Your Winning Rate. Redragon K521 Will Be Your Perfect Partner
  • 【12 Multimedia Combination Keys】The K521 Wired Gaming Keyboard is Equipped with 12 Multimedia Keys That Can Greatly Enhance Your Gaming/Office Efficiency and Make It More Convenient to Use
umask
mkdir -m 750 secure-data
stat -c '%A %a %U:%G %n' secure-data

A command such as mkdir -m 777 shared does not guarantee mode 777, and broad write access can let other users modify the directory’s contents. Choose permissions for the people and processes that need access rather than defaulting to 777.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Show each directory created with -v

By default, successful creation is quiet. Add -v (or --verbose) to print a message for each directory actually created:

mkdir -pv project/src/components

Typical output looks like this, though wording can vary by implementation and locale:

mkdir: created directory 'project'
mkdir: created directory 'project/src'
mkdir: created directory 'project/src/components'

Combine options

You can combine parent creation, a requested mode, and verbose output:

mkdir -p -m 750 -v project/secure/data

Short options can also be grouped, but options that take an argument can make a grouped command harder to read. For example, mkdir -pvm 750 project is less obvious to a beginner than the spaced form above.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Handle spaces and names that begin with a hyphen

Quote a path containing spaces so the shell passes it as one argument:

mkdir "Project Files"
mkdir -p "$HOME/Documents/Project Files/Reports"

Without quotes, mkdir Project Files passes two names, Project and Files. Quote variables for the same reason:

Rank #4
Sale
Logitech G413 SE Full-Size Mechanical Gaming Keyboard - Black
  • Take your gaming skills to the next level: The Logitech G413 SE is a full-size keyboard with gaming-first features and the durability and performance necessary to compete
  • PBT keycaps: Heat- and wear-resistant, this computer gaming keyboard features the most durable material used in keycap design
  • Tactile mechanical switches: Uncompromising performance is always within reach with this wired gaming keyboard
  • Premium color, material and finish: Elevate your gaming setup with this backlit keyboard featuring a sleek, black-brushed aluminum top case and white LED lighting
  • 6-Key rollover anti-ghosting performance: Experience reliable key input with this anti-ghosting keyboard versus non-gaming mechanical keyboards
dirname="Project Files"
mkdir "$dirname"

An unquoted variable such as mkdir $dirname can undergo word splitting and wildcard expansion.

A name beginning with a hyphen can be mistaken for an option. End option processing with --, or give the name an explicit relative-path prefix:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mkdir -- -reports
mkdir ./-reports

Use relative or absolute paths deliberately

A relative path such as mkdir output is short, but its destination depends on the current working directory. That can surprise you when a script or terminal session starts somewhere unexpected. Use pwd to check your location.

An absolute path names the destination from the filesystem root:

mkdir -p /tmp/example/output

Absolute paths are unambiguous, but paths under system-managed locations may require elevated privileges, and absolute paths may not suit other machines.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Understand permission errors and sudo

Creating a directory generally requires write permission on its parent and search (execute) permission to traverse the relevant path components. Inspect the path and its permissions before changing approach:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
pwd
ls -ld . ..
ls -ld /path /path/to /path/to/parent

For a directory that genuinely belongs in a protected system location, elevated privileges may be needed, for example:

Best Value
Sale
AULA F2088 Typewriter Style Mechanical Gaming Keyboard Wired, 104 Keys
  • Retro Typewriter Style Round Keycaps: Mechanical blue switch offers a quicker and springier response, crisp click sound, precise tactile feedback for ultimate gaming performance. Double-shot injection molded vintage steampunk round keycaps for clear backlight and extreme durability. The stepped floating keycap fit your fingertips perfectly for precise positioning, prevent fatigue and wrong typing. Comes with keycap puller for easy keycaps cleaning
  • Multimedia and Backlight Control Knob: This wired mechanical keyboard effortlessly controls media thanks to its dedicated media control keys. Quick-access buttons for media volume, backlight effect, music play, pause, switch. You can switch 19 different lighting effects or adjust the backlit brightness and speed. And you can create 3 customized backlight as you like. Long press knob for three seconds to switch between media and lighting modes
  • Metal Panel and Magnetic Wrist Rest: The computer keyboard panel is made of top-grade aluminium alloy material, with matte-finish texture, sturdy and robust enough to protect it from scratch. The ergonomic ABS palm rest provides firm support that alleviates pressure on your wrist from gaming at an elevated angle. The surface has a smooth and comfortable touch that enhances the feeling of the keyboard. USB connector for a reliable connection and ultimate gaming performance
  • 104 Keys Anti-Ghosting Programmable: This mechanical gaming keyboard features Anti Ghosting Technology which ensures your simultaneous keystrokes register the way you intended, allow multi-keys to work simultaneously with high speed. Each key is controlled by independent switch, let you enjoy high-grade games with fast response, boosting your performance! The PC Gaming Keyboard has been ergonomically designed to be a superb typing tool for office work as well
  • Stylish Durable and Wide Compatibility: Modern and sleek design with superior performance. High low key layout with suspended round key fits fingers effectively, help reduce hand fatigue, aluminum alloy metal panel, matte texture, sturdy and robust, protect it from scratch. Support PC Mac Laptop, Tablet, Desktop computer, suitable for Windows 7/8/10/XP/Vista, Linux and Mac OS systems. USB wired conection, plug and play! No drivers or softwares are required
sudo mkdir /srv/example
ls -ld /srv/example

sudo runs the operation as another user, usually root; it is not a general fix for commands targeting your home directory. A directory created as root may not be writable by your normal account. Prefer a user-owned location such as mkdir -p "$HOME/projects/example" when appropriate, and inspect ownership after an elevated creation.

Diagnose common mkdir errors

Symptom Likely cause What to check or do
No such file or directory A parent path component is missing and -p was not used. Check the path; use mkdir -p path/to/dir if the parents should be created.
File exists or an existing-path error The target exists as a file, symbolic link, or other incompatible object rather than a directory. Inspect it before taking action: ls -ld project and file project. Do not delete it automatically.
Permission denied The parent is not writable or a path component cannot be traversed. Inspect ownership and permissions along the path. Use sudo only if the destination should be created with elevated ownership.
No output Usually normal: successful mkdir is quiet. Verify with ls -ld name or add -v when creating.
Creation fails despite plausible permissions The filesystem may be read-only, out of space, out of inodes, or the user may have reached a quota. Check capacity and mount details with df -h ., df -i ., and mount | grep ' on '.
The path resolves somewhere unexpected A path component may be a symbolic link. Inspect it with ls -ld path/to/component and, where available, readlink -f path/to/component.
An option is unavailable or behaves differently The installed implementation or version may differ. Check the local command with mkdir --help and mkdir --version.

Linux documents errors for existing paths, permission failures, read-only filesystems, space exhaustion, quota exhaustion, and symbolic-link resolution in the mkdir(2) manual. The diagnostic commands above can help narrow down a cause; they do not guarantee a remedy.

Check the local command’s options

Ubuntu installations can carry different package versions, so consult the command installed on your system when you need a specific option or version detail:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mkdir --help
mkdir --version

Ubuntu’s packaged GNU mkdir(1) reference documents -p, -m, -v, --help, and --version. It also lists SELinux/SMACK context options such as -Z and --context; these are advanced and depend on the installed implementation and security configuration, not a normal prerequisite for creating directories on Ubuntu.

Use mkdir in a shell script

A successful command returns a success status; failures return a nonzero status. Test that result if the script must stop when a directory cannot be prepared:

if mkdir -p "$HOME/app/data"; then
    echo "Directory is ready"
else
    echo "Could not create directory" >&2
    exit 1
fi

For repeatable setup, mkdir -p is usually preferable to checking for a directory first and creating it separately. A separate check and creation can race with another process. The underlying Linux system call returns zero on success and an error on failure; the command exposes the outcome through its shell exit status, as described in the mkdir(2) reference.

Quick reference

Purpose Command Note
Create one directory mkdir name Parent must exist and be writable.
Create several directories mkdir one two three Each name is a separate operand.
Create missing parents mkdir -p a/b/c Also tolerates an existing target directory.
Request initial permissions mkdir -m 750 private Umask and default ACLs can affect the resulting mode.
Show created directories mkdir -v name Prints a message for each created directory.
Show local help or version mkdir --help / mkdir --version Reports the installed command’s information.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.