# How to use the Linux chown command to set new owners for files

With the [Linux command](https://www.ionos.com/digitalguide/server/configuration/linux-commands-an-overview-of-terminal-commands/) “chown” you can assign new owners or groups to files or folders. The command can be customized.

## What is the Linux chown command?

Usually, whoever creates a file or folder remains the owner of the file. However, if that has to be changed or if you want to change the group of a file or folder, [Linux](https://www.ionos.com/digitalguide/server/know-how/linux-the-cost-effective-alternative-to-windows/) has the right tool for you in the form of “chown”. Linux chown owes its name to the words **CHange OWNer**. With most [Linux distributions](https://www.ionos.com/digitalguide/server/configuration/linux-distributions/) such as [Debian](https://www.ionos.com/digitalguide/server/know-how/debian-the-universal-system-software/) or [Ubuntu](https://www.ionos.com/digitalguide/server/know-how/ubuntu-the-linux-system-for-everyone/) the command is part of the standard.

## How does the chown command work?

To designate a new owner for a file or folder using the Linux chown command, you can include the **username or user ID** of the new owner in the command. The Linux chown command retrieves the necessary information from the */etc/passwd* and */etc/group* files. Additionally, you can modify the group membership of the file or folder using this command.

## What’s the syntax of Linux chown?

The chown command always has the same basic syntax. It looks like this:

```bash
$ chown [Options] [Owner] [:[Group] File
```

However, there are a few different ways in which the name of the new owner and the group can be combined. Linux chown allows these combinations:

- **owner\_name:group\_name**: this changes the owner and group at the same time.
- **:group\_name**: only the group membership is changed; the owner name remains identical.
- **owner\_name**: only the owner is changed.
- **owner\_name:**: the owner is changed; the default group of the currently logged in user acts as the group.

## What are the options of Linux chown command?

There are several options that you can use to further specify the command. The most important ones are:

- **-c or --changes**: By using this option, the Linux chown command will only display files that have had their owner changed.
- **-f or --force**: If you use this option, error messages about failed change attempts will be suppressed.
- **-R or --recursive**: With this option you ensure that all subfolders and directories are also changed when the chown command is executed.
- **-v or --verbose**: This option allows you to see what Linux chown is doing.

## Examples of Linux chown

To provide a better understanding of how the Linux chown command is employed, here are a few examples:

```bash
$ chown Peter examplefile.txt
```

With this Linux chown command, the user Peter becomes the new owner of the file *examplefile.txt*.

```bash
$ chown $USER examplefile.txt
```

This means that the current user becomes the owner of the file *examplefile.txt*.

```bash
$ chown -cR Peter:files /media/documents
```

The user Peter becomes the owner for the directory */media/documents* and all associated subdirectories. In addition, these directories and the subfolders are transferred to the “files” group.


This is a markdown version of: [https://www.ionos.com/digitalguide/server/configuration/linux-chown-command/](https://www.ionos.com/digitalguide/server/configuration/linux-chown-command/) for AI/LLM consumption.