Skip to content
shellmap

mkdirCreate a new directory across all 5 shells

Equivalents in every shell

Bashunix
mkdir dir
Zshunix
mkdir dir
Fishunix
mkdir dir
PowerShellwindows
New-Item -ItemType Directory -Path dir

Also `mkdir` and `md` as aliases.

cmd.exewindows
mkdir dir

Both `mkdir` and `md` work.

Worked examples

Create nested directories

Bash
mkdir -p a/b/c
PowerShell
New-Item -ItemType Directory -Path a/b/c -Force
cmd.exe
mkdir a\b\c

Create multiple sibling directories

Bash
mkdir foo bar baz
PowerShell
foo, bar, baz | ForEach-Object { New-Item -ItemType Directory -Path $_ }
cmd.exe
mkdir foo bar baz

Create with specific permissions

Bash
mkdir -m 755 dir

Gotchas

  • cmd `mkdir` natively creates intermediate directories; Unix `mkdir` needs `-p` for the same behavior.
  • PowerShell `mkdir` is a wrapper function around `New-Item -ItemType Directory`; behavior matches cmd, not Unix.
  • Permission/mode flags are Unix-only — Windows ACLs are set via `icacls` or `Set-Acl`.

WSL & PowerShell Core notes

pwsh`mkdir` works on every pwsh platform but maps to different things: on pwsh 7+ Linux/macOS hosts it invokes the system `mkdir`, on Windows it is a wrapper function around `New-Item -ItemType Directory`. The portable cmdlet form is `New-Item -ItemType Directory -Path a/b/c -Force` — the `-Force` flag is the cross-platform equivalent of Unix `mkdir -p` (create missing parents, succeed if directory already exists). POSIX mode flags like `-m 755` are silently no-ops on Windows because NTFS uses ACLs, not POSIX permission bits.
WSLCreating a directory from inside WSL on a `/mnt/c/...` path works but the resulting NTFS directory inherits default Windows ACLs — a subsequent `chmod 700` from WSL will not actually restrict access. Conversely, directories created from Windows-side Explorer show up as mode `0777` from WSL because DrvFs synthesises permissive POSIX bits. For build artifacts or anything that needs strict Unix permissions, create them inside `~/` (the real ext4 WSL filesystem), not under `/mnt/c/`.

Related commands