$mkdir
Create new directories and folder hierarchies.
mkdir [OPTIONS] DIRECTORY...Try `mkdir` Live in Interactive Sandbox
Zero-install client simulation with real-time feedback.
Overview & How mkdir Works
`mkdir` (Make Directory) creates one or more new directories in the file system. With the `-p` (parents) flag, it can create complete nested directory paths in a single command without throwing errors if intermediate folders already exist.
Common Flags & Command Options
| Flag / Option | Description |
|---|---|
| -p, --parents | Create intermediate parent directories as needed without error if existing. |
| -m, --mode=MODE | Set file permission mode for new directories upon creation (e.g., -m 700). |
| -v, --verbose | Print a confirmation message for every created directory. |
Practical Real-World Examples
mkdir -p /home/user/workspace/src/components && ls -R /home/user/workspaceCreates workspace, src, and components directories automatically.
Frequently Asked Questions
Why should you always use mkdir -p in scripts?
`-p` prevents scripts from failing if the directory already exists and ensures all necessary parent directories are created automatically.
Related Linux Commands
Search for files and directories in a directory hierarchy based on name, type, size, or modification date.
List directory contents including file sizes, permissions, ownership, and modification timestamps.
Change the current working directory in the shell workspace.
Concatenate and print file contents directly to the terminal standard output.
Remove files or directories from the filesystem.
Copy files and directories to a destination path.