mkdir
Definition
mkdir is a command-line instruction that creates a new directory (folder). The name stands for “make directory.” It is available in Unix-like shells (bash, zsh), macOS Terminal, and is an alias to directory-creation commands in Windows PowerShell and Windows Terminal.
Why it matters
Creating directories is a fundamental part of organising files, structuring projects and preparing environments for build or deployment scripts. mkdir is used in manual workflows and automated scripts (installers, CI pipelines, setup scripts) so knowing its behaviour and common options prevents errors and permission issues.
Example in VCA
- mkdir ~/vibe-projects — creates a folder named vibe-projects in your home directory (the ~ expands to your home folder).
- cd ~/vibe-projects && mkdir env-test — creates the env-test folder inside vibe-projects.
- mkdir -p projects/backend/logs — creates the parent directories if they don’t exist; no error if the path already exists.
Notes: ~ is expanded by the shell; use quotes carefully ("~/dir" may still expand, but quoting can change behaviour in some scripts). On Unix-like systems you can use mkdir -m to set permissions and mkdir -p to make intermediate directories.
Another Real World Example
Create nested directories for a web app release on a Linux server:
- sudo mkdir -p /var/www/myapp/releases/2026-03-16
On Windows PowerShell the equivalent commands are:
- mkdir logs
- New-Item -ItemType Directory -Path logs
PowerShell maps mkdir to a directory-creation command, so the familiar shortcut works there too.
Common mistakes
- Not using -p and receiving an error when parent directories are missing.
- Expecting mkdir to overwrite files or replace existing directories; by default it fails if the directory exists (use -p for idempotent behaviour).
- Permission denied errors when attempting to create directories in protected locations (use sudo or appropriate privileges where required).
- Confusing relative and absolute paths (mkdir data creates a folder in the current directory; mkdir /data creates a root-level folder).
- Assuming case-insensitive names on all systems — Linux and macOS (HFS with case insensitivity optional) differ from Windows.
- Using Windows path separators () in Unix shells or forgetting to escape them in scripts.
- Quoting or escaping ~ incorrectly so it does not expand to the home directory.