CloudsArk
Commands Linux

chown Command Examples in Linux

Practice useful chown command examples for everyday Linux administration and troubleshooting.

chown Command Examples in Linux

Introduction

These examples show practical ways to use chown on a Linux terminal. Each example is written so you can adapt it for administration or troubleshooting.

Example 1: Basic Usage

sudo chown alice report.txt

This is the simplest form of the command and is a good starting point before adding options.

Example 2: Common Admin Task

sudo chown apache:apache /var/www/html/index.html

This example reflects a common task on RHEL, Rocky Linux, AlmaLinux, or similar systems.

Example 3: Useful Option

sudo chown -R deploy:deploy /srv/app

This option helps narrow the result, change behavior, or handle a more realistic target.

Example 4: Real-World Scenario

sudo chown :developers shared.txt

Use this pattern when the task moves beyond a single basic command.

Example 5: Verification

ls -l report.txt

Example output:

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

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
sudo chown -R deploy:deploy /srv/app
sudo chown :developers shared.txt
ls -l report.txt

Summary

Good chown usage means choosing the right option, keeping the target clear, and verifying the result with output you can explain.