Skip to content
shellmap

chgrpChange the group ownership of a file or directory on Unix systems across all 5 shells

Equivalents in every shell

Bashunix
chgrp devs file
Zshunix
chgrp devs file
Fishunix
chgrp devs file
PowerShellwindows
icacls file /grant "devs":(RX)

NTFS has no Unix-style "primary group" attribute. To give a *group* access to a file, add an ACL entry for the group with `icacls` or `Set-Acl`.

cmd.exewindows
icacls file /grant "devs":(RX)

Same idea — add an ACL entry for the group rather than setting a single group-owner field.

Worked examples

Give group `devs` read access to a file

Bash
sudo chgrp devs file.txt
PowerShell
icacls file.txt /grant "devs":(RX)
cmd.exe
icacls file.txt /grant "devs":(RX)

Recursively grant a group access to a directory tree

Bash
sudo chgrp -R devs /var/log/app
PowerShell
icacls C:\logs\app /grant "devs":(OI)(CI)RX /T
cmd.exe
icacls C:\logs\app /grant "devs":(OI)(CI)RX /T

Setgid: new files inherit the directory’s group

Bash
chmod g+s shared/
PowerShell
icacls shared /grant "devs":(OI)(CI)M

Gotchas

  • `chgrp` only changes the group; use `chown user:group` to set both owner and group in one step.
  • On Windows NTFS the "group that owns a file" field is vestigial (used by the deprecated SFU / SUA POSIX subsystems). Modern Windows ignores it — use ACL entries instead.
  • The setgid bit (`chmod g+s` on a directory) makes new files inherit the directory’s group on Unix. Windows has no exact equivalent; use `icacls` inheritance flags `(OI)(CI)` to apply a group ACL to new children.
  • Group names map to GIDs in `/etc/group`; if the group does not exist `chgrp` errors. On Windows, `icacls` resolves the group against the local SAM or Active Directory.

WSL & PowerShell Core notes

pwshPowerShell Core has no `chgrp` cmdlet on any platform. On Linux/macOS pwsh the system `chgrp` works. On Windows, "group ownership" is not a real attribute; grant the group permissions via `icacls <file> /grant "<group>":(<rights>)` or `Set-Acl` instead.
WSLOn the Linux side `chgrp` is fully functional. On `/mnt/c/...` it only persists if `metadata` is enabled in `/etc/wsl.conf` — and even then the change is invisible to Windows Explorer or `icacls`. To grant Windows-side group access, do it from cmd / PowerShell with `icacls`.

Common tasks using chgrp

Related commands