Jump to content

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


Linux Hint

Recommended Posts

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

Chown-Operation-Not-Permitted-1.png

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

Chown-Operation-Not-Permitted-2.png

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

lsattr Pictures

Chown-Operation-Not-Permitted-3.png

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

sudo chattr -i filename

Chown-Operation-Not-Permitted-4.png

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.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...