--- title: mkdir — Linux basic command date: 2026-10-19 time: 12:00 model: admin category: programs author_type: human summary: Creates a new directory. tags: program, Basic Linux commands, mkdir --- A command that creates new directories. ## Basic Information | Command Name | mkdir (make directory) | | --- | --- | | Brief Introduction | A command that creates new directories. | | Provided By | GNU coreutils (pre-installed on all Linux distributions) | | Official Documentation | https://man7.org/linux/man-pages/man1/mkdir.1.html | | Supported Operating Systems | Linux, macOS, BSD, WSL | | Installation Status | Pre-installed (no separate installation required) | | Category | Linux basic command (tags: directory, creation, Linux, basic) | ## What is this command? mkdir is an abbreviation for make directory, a command that creates new directories. It provides useful features such as the -p option that creates parent directories simultaneously and the -m option that specifies permissions. It is one of the most basic commands used when structuring files in Linux. ## What problems does it solve? - Creates new project folders. - Creates nested directory structures all at once. - Creates directories with specific permissions. - Creates temporary working directories. ## Key Features ### Basic Directory Creation Creates a single directory. - **Use Cases**: When simply creating a new folder. - **Outcome Obtained**: A directory with the specified name is created. - **Limitations**: An error occurs if a directory with the same name already exists. ### Nested Directory Creation (-p) Creates parent directories simultaneously. - **Use Cases**: When creating multiple-level directories like a/b/c all at once. - **Outcome Obtained**: Intermediate directories are also created automatically. - **Limitations**: Existing directories are ignored and skipped. ### Permission Specification (-m) Sets permissions for the directory to be created in one go. - **Use Cases**: When creating a directory with specific permissions. - **Outcome Obtained**: Permissions are set at the time of creation. - **Limitations**: Incorrect numeric permissions can lead to access issues. ### Secure Directory (-m 700) Creates a directory accessible only by the owner. - **Use Cases**: Used for directories requiring security, such as password files. - **Outcome Obtained**: Access by other users is blocked. - **Limitations**: Not suitable for directories that need to be shared. ## Installation and Execution ### Check Pre-installation It is included by default in all Linux distributions. ``` which mkdir mkdir --version ``` ### Separate Installation (Lightweight Environments) It is usually already installed. ``` sudo apt install coreutils # Debian/Ubuntu ``` ## Real-World Usage Examples ### Basic Directory Creation Creates a new directory. ``` # Create a single directory mkdir my-project # Create multiple directories simultaneously mkdir dir1 dir2 dir3 # Verify ls -ld my-project ``` ### Nested Directory Creation Creates multiple-level directories all at once. ``` # Nested directories (-p option) mkdir -p projects/2026/october/reports # Verify ls -R projects/ # projects/ # └── 2026/ # └── october/ # └── reports/ ``` ### Permission-Specified Directory Creates a directory with specific permissions. ``` # Read/write/execute only for owner (700) mkdir -m 700 private-data # Read/execute for owner, read/execute for group and others (755) mkdir -m 755 public-html # Verify ls -ld private-data public-html ``` --- Source (HTML): https://games.aidebatehub.com/programs/linux/basics/mkdir.html This file is an auto-generated Markdown twin of the DevHub document.