| by Arround The Web | No comments

How to Resolve the “Chown Operation Not Permitted” Error in Linux

In Linux, chown is used to modify the owner permissions of files and directories. However, while using the “chown” command, users encounter the “Chown Operation Not Permitted” error. It occurs due to different problems such as insufficient permissions, file system restrictions, the desired file being immutable, or being locked by other processes.

Many Linux users face the “Chown Operation Not Permitted” issue which sometimes leads to major issues. So, if you also require some methods to fix the error, this short tutorial is for you. Here, we will describe the simple methods to resolve the “Chown Operation Not Permitted” error in Linux.

How to Resolve the “Chown Operation Not Permitted” Error in Linux

The “Chown Operation Not Permitted” error can occur for various reasons, and your initial task is identifying that reason. So, we will divide this section into multiple parts to explain the different reasons and their fixes.

1. Insufficient Permission
The “Chown Operation Not Permitted” error mainly occurs because the user using this command is neither the root user nor the file owner. These are the only people who are permitted to change the owners of a file:

sudo chown user file

This command modifies the ownership for the specified file to the mentioned user. For example, let’s provide access to the “Pictures” directory to Andrew:

sudo chown Andrew ~/Pictures

2. Locked File
You can also encounter this error if the file for which you are using the “chown” command is being used by some process. It includes if you kept it open in the background. Hence, you need to close it or wait for the processes to finish so that the file becomes available. This resolves the “Chown Operation Not Permitted” error.

3. Immutable File
Sometimes, the error occurs when a directory or file is set to immutable. As a beginner, you may be unfamiliar with immutable files. Users set the files to immutable so that no one else can modify, rename, or remove them. Since “immutable” is a file attribute, you can check if a file is immutable using the following command:

lsattr

By entering this command, you’ll get a list of files along with their attributes in the following format:

lsattr Pictures

Now, to resolve the error, use the following command and then remove the immutable attributes:

sudo chattr -i filename

After that, you can proceed with your tasks because this error won’t be a hurdle anymore.

Conclusion

Changing the ownership of the files is quite a common task in Linux, but some errors stop the users from doing so. In this guide, we briefly explained how to resolve the “Chown Operation Not Permitted” error. Mostly, the error is resolved when the users use the sudo utility. Moreover, we recommend you to provide an access carefully. Otherwise, you may lose the data due to unauthorized access.

Share Button

Source: linuxhint.com

Leave a Reply