Every item on a Linux filesystem—whether a file, folder, or directory—carries metadata about who controls it. This metadata includes a user, a group, and a set of access rights. Knowing how to change owner of folder Linux properly is a skill every administrator needs.
Reasons You Might Need to Change Owner of Folder Linux
| Scenario | Explanation |
|---|---|
| Restricting access | A folder must only be reachable by one specific account |
| Employee departure | Data folders must be reassigned to revoke old privileges |
| Script execution | Bash or Python programs may require read/write access, so the correct proprietor must be set |
| Network transfers | Moving data across machines often results in mismatched ownership |
How to Check Current Folder Ownership in Linux
Before you change owner of folder Linux, check who currently controls the target path:
$ ls -l MyProjectData
$ ls -l -d MyProjectData
The output displays three key columns:
| Column | What It Shows |
|---|---|
First (e.g., drwxr-xr-x) |
Permission flags |
Second (e.g., alex) |
The user who owns the folder |
Third (e.g., alex) |
The group tied to the folder |
Suppose user alex and group alex control MyProjectData along with its contents.
-d flag tells ls to display information about the directory itself, not its contents.
The chown Utility: Syntax Overview
The chown command belongs to the GNU Coreutils package. Its job is reassigning user and group ties on files and folders.
$ chown [OPTION]... [OWNER][:[GROUP]] FILE...
| Component | Meaning |
|---|---|
OWNER |
The new user to assign |
:GROUP |
The new group to assign (preceded by a colon) |
FILE |
One or more target files or folders |
Identifying Available Users and Groups
Confirm which accounts and groups exist on your machine. Print all registered accounts:
$ getent passwd
Print all registered groups:
$ getent group
If the desired account does not exist yet, create one with adduser:
$ sudo adduser mentor
$ sudo adduser mentor sudo
This registers a fresh account called mentor and grants it elevated privileges.
How to Change Owner of Folder Linux with chown
To change owner of folder Linux from alex to mentor:
$ sudo chown mentor MyProjectData
Verify the result:
$ ls -l -d MyProjectData
The second column should now read mentor.
chown. Running it without sudo on folders you do not own will return a permission denied error.
Modifying Both User and Group at Once
Reassign both the user and the group in a single step:
$ sudo chown mentor:mentor MyProjectData
Both the owner and the group fields for MyProjectData will now display mentor.
OWNER: format (colon, no group name) to set the group to the login group of the specified user automatically.
Applying Ownership Changes Recursively to All Nested Contents
The parent folder might belong to mentor, but items inside it could still carry old assignments. Propagate the update through every subfolder and file with the -R flag:
$ sudo chown -R mentor:mentor MyProjectData
Confirm by listing both the parent and its contents:
$ ls -l -d MyProjectData
$ ls -l MyProjectData
Every entry should now reflect mentor as the user and group.
-R flag follows directory trees but does not cross filesystem boundaries by default. Add --no-preserve-root only if you fully understand the consequences.
Quick Reference for chown Commands
| Action | Command |
|---|---|
| Reassign only the user | sudo chown mentor FolderName |
| Reassign user and group together | sudo chown mentor:mentor FolderName |
| Reassign recursively through all nested items | sudo chown -R mentor:mentor FolderName |
If you also need to adjust read/write/execute bits separately, look into the chmod command, which handles permission modes rather than ownership. For a deeper look at how the chown system call works at the kernel level, the Linux man pages offer thorough documentation.
FAQs
chown stands for “change owner.” It is a command-line utility that reassigns user and group ownership on files and directories in Linux and other Unix-like systems.
No. Ownership changes require root privileges. Run chown with sudo, or switch to the root account first using su -.
Add the -R flag to the chown command. For example: sudo chown -R newuser:newgroup /path/to/folder. This applies the change to all subfolders and files.
chown changes who owns a file or folder (user and group). chmod changes what the owner, group, and others can do with it (read, write, execute permissions).
Yes. By default, chown changes ownership of the target file a symlink points to, not the symlink itself. Use the -h flag to change ownership of the symlink instead.