Change file permissions
Modify read/write/execute permissions on a file or directory.
How to change file permissions in each shell
Bashunix
chmod 644 file.txtSymbolic form: `chmod u+x script.sh` adds execute for the owner. `chmod -R` recurses; combine with `find ... -type f -exec chmod 644 {} +` to skip directories.
Zshunix
chmod 644 file.txtFishunix
chmod 644 file.txtPowerShellwindows
icacls file.txt /grant Everyone:RXWindows uses ACLs, not mode bits — there is no direct chmod equivalent. `icacls /grant` adds permission entries; `/inheritance:r` resets inheritance.
cmd.exewindows
icacls file.txt /grant Everyone:RXSame `icacls.exe` binary as PowerShell. Permission tokens: `R`=read, `W`=write, `RX`=read+execute, `M`=modify, `F`=full control.
Equivalents listed for Bash, Zsh, Fish, PowerShell, cmd.exe.
Gotchas & notes
- Unix mode bits and Windows ACLs are **fundamentally different models**. A `chmod 755` file shared via SMB to Windows has its mode bits collapsed into a coarse ACL — exact permissions do not round-trip.
- On WSL, `chmod` against a file under `/mnt/c` updates **metadata stored in NTFS extended attributes**, but only takes effect when the drive is mounted with `metadata` (set in `/etc/wsl.conf`). Without it, every file appears as 755/777.
- PowerShell `Set-Acl` is the cmdlet-native ACL editor: `$acl = Get-Acl file.txt; $acl.SetAccessRuleProtection($true,$true); Set-Acl file.txt $acl`. `icacls.exe` is usually faster for one-off changes.
- To recursively `chmod` only files (not directories): `find . -type f -exec chmod 644 {} +`. Mixing files and directories under one numeric mode (`chmod -R 644 .`) makes directories unenterable.