How to Fix chown Operation Not Permitted
In this tutorial, you'll learn about How to Fix chown Operation Not Permitted. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.
The Problem
You run chown to change file ownership and get:
chown: changing ownership of 'file.txt': Operation not permitted
Or:
chown: cannot access 'file.txt': Permission denied
On Linux, only the root user can change the owner of a file. Regular users cannot transfer ownership even if they own the file.
Quick Fix
Step 1: Use sudo
sudo chown user:group file.txt
Enter your password when prompted.
Step 2: Verify ownership
ls -la file.txt
Expected output:
-rw-r--r-- 1 user group 1024 Mar 15 10:30 file.txt
Step 3: Change group only (user can do this)
If you own the file, you can change the group to any group you are a member of:
chown :mygroup file.txt
Or use chgrp:
chgrp mygroup file.txt
Step 4: Recursive ownership change
For directories, use the -R flag:
sudo chown -R user:group /path/to/directory
Alternative Solutions
If you do not have sudo access, request ownership via an admin:
# Admin command
sudo chown your-username file.txt
On some systems, chown is restricted by the CAP_CHOWN capability. Check with getcap:
getcap /usr/bin/chown
Prevention
- Plan file ownership before creating shared directories.
- Use group ownership for collaborative projects.
- Run application services under dedicated users, not root.
- Use ACLs (
setfacl) for fine-grained permissions without changing ownership.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro