Skip to content
shellmap

chmodChange file mode bits — read / write / execute permissions on Unix across all 5 shells

Equivalents in every shell

Bashunix
chmod 755 file
Zshunix
chmod 755 file
Fishunix
chmod 755 file
PowerShellwindows
icacls file /grant Users:(RX)

Windows uses ACLs, not Unix mode bits. `icacls` (built into every Windows version) is the most direct equivalent; for PowerShell-native control use `Get-Acl` / `Set-Acl`. PowerShell 7 on Linux / macOS calls the system `chmod` binary.

cmd.exewindows
icacls file /grant Users:(RX)

No Unix-style `755` / `644` mode bits on NTFS — only ACL entries. `icacls` is the built-in tool.

Worked examples

Make a script executable

Bash
chmod +x deploy.sh
Fish
chmod +x deploy.sh

Recursively set read + execute permissions on a directory

Bash
chmod -R 755 dir
PowerShell
icacls dir /grant Users:(OI)(CI)RX /T
cmd.exe
icacls dir /grant Users:(OI)(CI)RX /T

Restrict a file to the owner only

Bash
chmod 600 secret.key
PowerShell
icacls secret.key /inheritance:r /grant:r "$env:USERNAME":(F)
cmd.exe
icacls secret.key /inheritance:r /grant:r %USERNAME%:(F)

Gotchas

  • Numeric modes (`chmod 755`) and symbolic modes (`chmod u+x`) coexist; pick one style per script. `755` = owner rwx, group r-x, others r-x.
  • Windows NTFS has no Unix mode bits — `chmod` exists inside Git Bash and WSL but only affects POSIX-emulated metadata, not real ACLs visible to native tools.
  • `chmod 777` is almost always wrong outside `/tmp`-style scratch directories; it grants world-write and is a common security misconfiguration.
  • `icacls` inheritance flags: `(OI)` object inherit (files), `(CI)` container inherit (subdirs), `(IO)` inherit-only. Combine to mimic `chmod -R`.

WSL & PowerShell Core notes

pwshPowerShell Core has no `chmod` cmdlet. On Linux/macOS pwsh, call the system `chmod` directly. On Windows pwsh, use `icacls` (procedural) or `Get-Acl` / `Set-Acl` (object-oriented). Scripts that need to run on every platform usually branch on `$IsWindows`.
WSL`chmod` on the WSL Linux filesystem (`~/...`) works exactly as it does on real Linux. On NTFS mounts (`/mnt/c/...`) mode bits are ignored by default — everything reports `0777`. To make `chmod` actually persist on `/mnt/c`, enable `[automount] options = "metadata"` in `/etc/wsl.conf` and restart WSL.

Common tasks using chmod

Related commands