# chown

> A command that changes which user and group own a file.

**Field:** Infrastructure  
**Category:** Linux & the Command Line  
**Also known as:** chown Command, Change Owner, File Ownership

## Think of it like

Think of it like writing a new name on a lunch box. Now it belongs to someone else.

## Definition

chown changes who owns a file or folder. You give it a user, and you can add a group after a colon. Only the root user can give a file away, so you usually run it with sudo. Add -R to change a folder and everything inside it. The owner is the person the first set of rights applies to.

## Example

Jack copies a website into place with sudo, so root owns it. The web server cannot write to it until Jack runs chown.

## Example code

```console
$ sudo chown www-data:www-data index.html
$ ls -l index.html
-rw-r--r-- 1 www-data www-data 512 Nov 16 10:05 index.html
```

The page now belongs to www-data. On Ubuntu, that is the user the web server runs as.

## Why it matters

A program can only use files that its user may touch. A wrong owner is a common cause of errors.

## Common mistake

Running chown -R on the wrong folder, like /. It can break the whole system.

## Three principles

- **User:group.** Set both at once.
- **Needs sudo.** Only root gives files away.
- **-R for folders.** Changes everything inside.

## Related terms

- [chmod](https://learn.benibix.com/term/infrastructure/chmod)
- [File Permissions](https://learn.benibix.com/term/infrastructure/file-permissions)
- [User Group (Linux)](https://learn.benibix.com/term/infrastructure/user-group)
- [sudo](https://learn.benibix.com/term/infrastructure/sudo)
- [Root User](https://learn.benibix.com/term/infrastructure/root-user)

## Told apart from

- [chmod vs chown](https://learn.benibix.com/compare/chmod-vs-chown): People often mix up chmod and chown because the names are so close. chmod changes what can be done to a file: read, write or run. chown changes who the file belongs to. A permission denied error can need either one, so read ls -l first and see which part is wrong.

## Taught in

- [Linux File Permissions](https://learn.benibix.com/learn/infrastructure-linux/linux-file-permissions): Linux CLI, 6/10

![The line -rwxr-x--- lucy devs run.sh split into labelled parts. The first three letters rwx belong to the owner lucy and add up to 7. The next three r-x belong to the group devs and add up to 5. The last three dashes belong to everyone else and add up to 0. Under each letter, r is 4, w is 2 and x is 1.](https://learn.benibix.com/diagrams/inf3-permissions.svg)

---

Source: https://learn.benibix.com/term/infrastructure/chown
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
