Fix: chown “operation not permitted” error

The change of ownership is a basic task in Linux. Sometimes, a user leaves the group or company, and you want to change the ownership of the files or directories for that user. The “chown” command is utilized to change the ownership, but it requires sudo privileges.

The error “chown” operation not permitted can usually occur while transferring ownership. This guide will discuss the reason and solutions for chown errors with this timeline:

Let’s start!

Reason 1: No Root/Sudo Permission

The main reason for the “operation not permitted” error is that the chown is not logged in as a root user or does not have sudo privileges. The sudo/root user can only modify the ownership of a file. Let’s remove this error by using the sudo permissions.

$ chown Milton testFile.txt

Solution: Login as Root / Sudo Privileges User

The sudo/root user has permission to change the system settings like, adding or removing a user or changing the ownership. For instance, to change the owner of the “testFile.txt” to “Milton”, use the following command:

$ sudo chown Milton testFile.txt

To verify the ownership of the file changed or not, use the below command:

$ ls -l testFile.txt

The “testFile.txt” output shows that the ownership of the file is changed to “Milton” and the group is the same.

If you change the directory ownership without the “operation not permitted”, use the chmod command with the “sudo” privileges. For example, to change the ownership of the directory “SampleFolder”, use the below command:

$ sudo chown Miltion SampleFolder

Reason 2: Immutable Attribute on Specific File

Another but less common reason for the chown “operation not permitted ” error is the file has an immutable attribute set. The immutable file attribute does not allow the users to change anything in the file. If we want to change the ownership of the file, the immutable attribute needs to be removed.

Let’s perform its solution.  

Solution: Remove the Immutable Attribute

The immutable attribute of a filename can be removed using the “chattr command “i” option. For example, to remove the immutable attribute for the “testFile1.txt”, the below command is utilized: 

$ chattr -i testFile1.txt

Now, we can change the ownership of the desired file. To change the “testFile1.txt” ownership to “Milton”, use this command:
Note:ls” is used to verify the details of the specified file.

$ sudo chown Milton testFile1.txt $ ls -l testFile1.txt

The ownership was successfully transferred to the “Milton”.

That’s the end.


The chown “operation not permitted” error can be removed using the sudo privileges or removing the immutable attribute of the file. The major cause of this error is not having the sudo privileges, which can be used with “sudo chown <owner-name> <file-name>”. Moreover, the immutable attribute can be removed using “chattr -i <file-name>” to allow the user to change the attribute. Following this guide, you have learned to fix the error “chown “operation not permitted””.