Menu
Coddy logo textTech

File Ownership

Part of the Fundamentals section of Coddy's Terminal journey — lesson 57 of 82.

Beyond permissions, every file has an owner and a group associated with it. When you run ls -l, you can see this ownership information right after the permission string:

-rw-r--r-- 1 alice developers report.txt
              │     │
              │     └── Group
              └──────── Owner

The owner is typically the user who created the file, and the group allows multiple users to share access. You can change ownership using the chown command:

# Change the owner of a file
chown bob report.txt

# Change both owner and group
chown bob:staff report.txt

# Change only the group
chown :staff report.txt

There's also the chgrp command, which changes only the group:

chgrp developers project.txt

Changing ownership usually requires administrative privileges. This is why you'll often see these commands used with sudo on real systems. Understanding ownership helps you control exactly who the "owner" and "group" permissions apply to when you set them with chmod.

Cheat sheet

Every file has an owner and a group. You can see this information with ls -l:

-rw-r--r-- 1 alice developers report.txt
              │     │
              │     └── Group
              └──────── Owner

Use chown to change ownership:

# Change the owner
chown bob report.txt

# Change both owner and group
chown bob:staff report.txt

# Change only the group
chown :staff report.txt

Use chgrp to change only the group:

chgrp developers project.txt

Changing ownership usually requires administrative privileges (use with sudo).

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals