Skip to content
shellmap

chownChange the owner (and optionally the group) of a file or directory across all 5 shells

Equivalents in every shell

Bashunix
chown user file
Zshunix
chown user file
Fishunix
chown user file
PowerShellwindows
$a = Get-Acl file; $a.SetOwner([System.Security.Principal.NTAccount]"user"); Set-Acl file $a

Changing owner on Windows needs `SeTakeOwnershipPrivilege` (Administrator). `takeown /F file` is the quick `sudo chown $(whoami) file` equivalent.

cmd.exewindows
takeown /f file

Takes ownership for the current admin user. To set ownership to a specific account, use `icacls file /setowner <user>` (also admin-only).

Worked examples

Change owner to user `alice`

Bash
sudo chown alice file.txt
PowerShell
$a = Get-Acl file.txt; $a.SetOwner([System.Security.Principal.NTAccount]"alice"); Set-Acl file.txt $a
cmd.exe
icacls file.txt /setowner alice

Change owner and group together

Bash
sudo chown alice:devs file.txt
Fish
sudo chown alice:devs file.txt

Recursively change owner of a directory

Bash
sudo chown -R alice /var/log/app
PowerShell
Get-ChildItem -Recurse C:\logs\app | ForEach-Object { $a = Get-Acl $_.FullName; $a.SetOwner([System.Security.Principal.NTAccount]"alice"); Set-Acl $_.FullName $a }
cmd.exe
icacls C:\logs\app /setowner alice /T

Gotchas

  • On Unix only `root` (via `sudo`) can change ownership to another user; the file owner can only `chown` to themselves or to a group they belong to.
  • On Windows, only Administrators or holders of `SeRestorePrivilege` can change ownership — and the change does NOT preserve the previous owner’s ACL entries.
  • `chown user:` (trailing colon, no group) sets the group to the user’s login group on GNU `chown`; BSD `chown` (macOS pre-Sonoma) errors out.
  • `takeown /F` always sets ownership to the *current* admin account; to give ownership to someone else use `icacls /setowner <user>`.

WSL & PowerShell Core notes

pwshPowerShell Core has no `chown` cmdlet. On Linux/macOS pwsh the system `chown` is used. On Windows, ownership is changed via `Get-Acl` → `SetOwner()` → `Set-Acl`, or the `icacls /setowner` / `takeown` external tools — all of which require Administrator and `SeTakeOwnershipPrivilege`.
WSLOn the WSL Linux filesystem, `chown` behaves exactly like on real Linux. On `/mnt/c/...`, ownership changes are stored as POSIX metadata only — and only if `metadata` is enabled in `/etc/wsl.conf`’s `[automount]` section. Native Windows tools (`icacls`) see no change either way.

Common tasks using chown

Related commands