CloudsArk
Commands Linux

What Is the chown Command in Linux?

Learn what the chown command does in Linux, how its syntax works, and when to use it.

What Is the chown Command in Linux?

Introduction

The chown command changes file owner and group ownership. It is useful for beginners, Linux administrators, DevOps engineers, and RHCSA students because it solves practical terminal tasks.

What the Command Does

Use chown to work with the specific Linux object it manages. Before changing anything, identify the target and run a read-only check when possible.

Basic Syntax

chown OWNER[:GROUP] FILE

The syntax includes the command, any options, and the target object.

Common Options

  • -R: change ownership recursively.
  • -v: show each ownership change.
  • --reference=FILE: copy owner and group from another file.

Practical Examples

sudo chown alice report.txt
sudo chown apache:apache /var/www/html/index.html
sudo chown -R deploy:deploy /srv/app
sudo chown :developers shared.txt

Verification command:

ls -l report.txt

Example output:

-rw-r--r-- 1 alice admins 1200 May 30 10:00 report.txt

When to Use This Command

Use chown when files are owned by the wrong user or service account. It is common after copying files as root, deploying web content, or restoring backups.

Common Mistakes

  • Running recursive chown from the wrong directory and changing too much.
  • Changing only the user when the service also requires a specific group.
  • Using a username or group name that does not exist on the target system.

Quick Reference

sudo chown alice report.txt
sudo chown apache:apache /var/www/html/index.html
ls -l report.txt

Summary

The chown command is safest when you understand the target, choose the right option, and verify the result with a separate command.