- 1View File Permissions in Linux
- 2Change File Permissions with chmod in Linux
- 3How to Use Numeric Mode with chmod in Linux
- 4chmod Symbolic Mode in Linux
- 5How to Change File Ownership in Linux
- 6How to Change Group Ownership Using chgrp in Linux
- 7Understanding Linux File Permission Symbols (r, w, x)
- 8Linux File Permissions - User, Group, Others
- 9Understanding Special Permissions in Linux: SUID, SGID, and Sticky Bit
- 10How to Use ACLs in Linux - Set File Permissions
- 11Set ACL Permissions in Linux with setfacl
- 12How to View ACLs using getfacl in Linux
- 13Find Files by Permissions in Linux
How to Change File Ownership Using chown
How to Change File Ownership Using chown in Linux
Welcome to this Linux tutorial! 👋
Today we’re going to learn a powerful command used for managing files and permissions — the chown command.
So, what does chown do?
chown stands for “change ownership.” It allows us to change who owns a file or directory on a Linux system.
Let’s start with a simple real-life example...
👨💻 Example Scenario
Imagine you’re an admin and you’ve just created a file, but now you want to assign it to another user named john. Here’s how you do it.
sudo chown john file.txt
This command changes the owner of file.txt to the user john.
Let’s walk through it step by step.
🔍 Step 1: Check Current Ownership
We’ll use the ls -l command to check who owns the file.
ls -l file.txt
-rw-r--r-- 1 root root 0 Jul 2 11:00 file.txt
Here, the file is owned by root (user and group).
🔧 Step 2: Change Ownership to Another User
sudo chown john file.txt
This changes the user owner to john, but keeps the group as it is.
Verify again:
ls -l file.txt
-rw-r--r-- 1 john root 0 Jul 2 11:00 file.txt
👥 Step 3: Change Both User and Group Ownership
Let’s say you also want to change the group to john’s group:
sudo chown john:john file.txt
That’s user:group format.
-rw-r--r-- 1 john john 0 Jul 2 11:00 file.txt
Perfect! 🎯
📁 Bonus: Change Ownership Recursively
What if you want to change ownership for a folder and everything inside it?
sudo chown -R john:john my_folder/
The -R flag makes the operation recursive, changing ownership for all subfolders and files too.
🧠 Summary
chown user file— change file ownerchown user:group file— change owner and groupchown -R user:group folder/— recursive change
That’s it! 🎉 You now know how to change file ownership using chown in Linux.
Practice it, and you’ll get comfortable managing permissions like a pro!
Next Topic ⮕How to Change Group Ownership Using chgrp in Linux
Comments
Loading comments...