LEARN THE MKDIR COMMAND IN UNDER 1 MINUTE #LINUX #SHORTS

Published: December 1, 2025 (Updated: Dec 1, 2025)

Enjoying this content? Subscribe to the Channel!

Mastering the mkdir Command: The Essential Guide to Creating Directories in Linux

Welcome to Darren’s Tech Tutorials!

Directory management is the backbone of any healthy Linux file system. Whether you are organizing configuration files or setting up a new development environment, knowing how to efficiently create new folders is absolutely fundamental.

Today, we are diving deep into the powerful, yet straightforward, mkdir command. This single command is all you need to create directories, but its optional arguments unlock amazing efficiency—allowing you to handle complex nested paths and even set security permissions right as you create them!


Understanding the mkdir Command

The mkdir command (short for MaKe DIRectory) creates a new directory with a specified name. If you do not provide a path, the new directory will be created in your current working directory.

Basic Syntax

The most straightforward use of the command requires just one argument: the name of the directory you wish to create.

Command Action
mkdir directory_name Creates a new directory named directory_name in your current location.

Example:

mkdir neuter

This command successfully creates a new directory named neuter in the directory you are currently working in. Simple as that!


Building Complex Paths: The -p (Parents) Option

One of the most common stumbling blocks for new users is creating a complex directory structure where some of the required parent folders do not yet exist. If you tried to create /path/to/my/new/folder and /path/to/my didn’t exist, the basic mkdir command would fail.

This is where the -p option comes to the rescue. The -p flag tells mkdir to create any necessary parent directories along the path if they are missing.

How to Use -p

To ensure your full directory path is created, just include the -p flag before the path:

mkdir -p path/to/neuter

What happens here?

  1. If the directory path does not exist, it is created.
  2. If the directory to does not exist, it is created inside path.
  3. Finally, the new directory neuter is created inside path/to.

This saves you multiple steps and commands, making directory setup incredibly fast and efficient.


Security First: Setting Permissions with the -m (Mode) Option

In Linux, directory security is controlled by permissions, often represented by a three-digit numerical code (like 755 or 700). Typically, you would create a directory and then use the chmod command to set permissions afterward.

The -m (mode) option allows you to set the permissions right as the directory is created, saving you a separate step!

Setting Permissions During Creation

To use the -m option, provide the numeric permission code directly after the flag.

Example 1: Setting Standard Permissions (Owner Read/Write/Execute, Group Read/Execute, Others Read/Execute)

mkdir -m 755 neuter

This creates the directory neuter and immediately sets its permissions to 755.

Example 2: Combining Power and Security

You can combine the -p and -m options for maximum efficiency, especially when setting up secure private areas.

Imagine you need to create a private directory for a user, ensuring only the owner can access it (permissions 700), and you are not sure if the parent directories exist:

mkdir -p -m 700 home/user/private

This command performs three tasks simultaneously:

  1. Creates any missing parent directories (home and user).
  2. Creates the final directory private.
  3. Sets the permissions of private to 700 (owner read, write, and execute; no access for anyone else).

Summary of Essential mkdir Arguments

Option/Argument Purpose Example
Path/Name Specifies the location and name of the directory. mkdir my_folder
-p Creates parent directories as needed (creates nested structures). mkdir -p a/b/c
-m MODE Sets the permissions (mode) of the created directory. mkdir -m 700 secret_data

Conclusion: Take Control of Your File System

The mkdir command is far more versatile than it looks! By mastering the -p and -m options, you transform directory creation from a slow, multi-step process into a single, lightning-fast command. This level of efficiency is crucial for anyone serious about managing a Linux environment.

Open up your terminal right now and start practicing these new tricks to build out your file system mastery!

If this tutorial helped you streamline your workflow, please hit that like button, subscribe to Darren’s Tech Tutorials for more clear guides, and let us know in the comments what essential Linux command we should tackle next! Happy computing!