chown Command Generator
Generate chown commands to change file owner and group (supports user:group, --reference, recursive)
Getting Started with chown
## What is chown?
`chown` (change owner) changes the user and/or group that owns a file or directory. Only the current owner or root can run it. Ownership is stored as a numeric UID/GID, but `chown` accepts names that it resolves through `/etc/passwd` and `/etc/group`.
## How to Use
1. **Set the owner**: Enter a username in the `user` field, or leave it blank to keep the current owner. 2. **Set the group**: Enter a group name in the `group` field, or leave it blank to keep the current group. Use `group` only (with user empty) to change just the group — the command becomes `:group`. 3. **Pick the file**: Enter the target path in the `file` field. 4. **Toggle options**: `-R` recursive, `-v` verbose, `--reference` to copy ownership from another file. 5. **Copy & Run**: Prefix with `sudo` if you are not the current owner.
Ownership Syntax & Options
### `user:group` combined form Change both owner and group at once: `chown nginx:www-data file.txt`.
### `user` owner only Change only the owner, group is untouched: `chown nginx file.txt`.
### `:group` group only Change only the group (leading colon): `chown :www-data file.txt`. Equivalent to `chgrp www-data file.txt`.
### `-R` Recursive Apply the change to a directory and everything inside it: `chown -R nginx:www-data /var/www`. Use with care — it can affect thousands of files.
### `-v` Verbose Print every file that `chown` processes, including ones whose ownership did not change.
### `--reference=FILE` Copy the user and group from another file instead of naming them explicitly: `chown --reference=template.txt new.txt`.
▶What is the difference between chown and chmod?
▶Why does chown say 'Operation not permitted'?
▶How do I change ownership of an entire directory tree?
If this tool has been helpful to you, consider buying me a coffee.
Buy me a coffee