As a Linux user, you can change the permissions of a file or directory you own. But can you change the ownership of a file or directory that you own? The answer is No. A Linux user cannot change the ownership of a file even if the user owns the file. The way Linux file permissions work, you cannot give away the ownership of a file or folder you own. For example, I have logged into my Ubuntu Linux system as the user ben. In the home directory I have a text file called file1.

Now I will run the chown command and try to change the file owner to root.

lchown operation not permitted

Only the root user or a user with root privileges may change the owner of the file. So you have to run the chown command as the root user or you can run the chown command with sudo.

Note that to run Linux commands with sudo privileges, you need to be a member of the sudo admin group. A user can change the group owner of a file if the user owns the file, but only if the user is a member of the target group. Which means, A Linux user may change the group owner of a file if following two conditions are satisfied:. For Example, let's think user Ben wants to change the group owner of the file1.

The file1. Now Ben wants to change the group owner to admin user group. If Ben is not a member of the admin group, chmod command will give the same error message "chown operation not permitted". These restrictions do not apply to the root user or when you execute the chown command with sudo privileges.

Problem: chown operation not permitted The way Linux file permissions work, you cannot give away the ownership of a file or folder you own.

Changing the Group Owner A user can change the group owner of a file if the user owns the file, but only if the user is a member of the target group.

Which means, A Linux user may change the group owner of a file if following two conditions are satisfied: The user must own the File or the Directory.

lchown operation not permitted

The user must be a member of the new group. To be able to change the group owner to admin, Ben must be a member of the admin user group.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I am working on a raspberry pi and am having a tough time giving permissions to an external hard drive that I have mounted using the following tutorial:.

I have now created folders on that external hard drive and when I do a ls -l command I get the following returned:. Now I'm trying to give it all write read and execute permissions or even change the owner and group to pi:pi. However, chmod is not working — it doesn't return an error, just seems to have no effect. This is a linux question but I think someone with background and knowledge of using a raspberry pi can help me out here.

The reason is because the ownership and permissions are defined at mount time for the vfat FS. Only do this if you're not accessing the the external hard drive from a windows computer:.

You can find tutorials for doing this on the web. How are we doing? Please help us improve Stack Overflow. Take our short survey. Learn more. Asked 5 years, 7 months ago. Active 2 years, 8 months ago. Viewed 45k times. Either that, or it is mounted read-only. To the OP: what is the mountpoint?

VFAT ist is. VFAT does not support ownership. Active Oldest Votes. Manual page mount 8 : Mount options for fat. Default: the uid and gid of the current process. The default is the umask of the current process. The value is given in octal. Let us continue this discussion in chat. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.

Email Required, but never shown. The Overflow Blog. Podcast Cryptocurrency-Based Life Forms. Q2 Community Roadmap.

Learn g02 g03

Featured on Meta. Community and Moderator guidelines for escalating issues via new response…. Feedback on Q2 Community Roadmap.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up. I don't understand why it doesn't allow me to chown file that I own without su privileges.

Obviously I can use sudo, but I'd like to understand why? Non-privileged users not root cannot chown files to other user names. To use chowna user must have the privileges of the target user. In other words, only root can give a file to another user. As explained here thanks slhck :. Only processes with an effective user ID equal to the user ID of the file or with appropriate privileges may change the ownership of a file.

The reason for this restriction is that giving away a file to another user can allow bad things to happen in uncommon, but still important situations.

For example:. Sign up to join this community.

The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered. Asked 6 years, 3 months ago. Active 4 years, 4 months ago. Viewed k times. I'm logged in as minime. Active Oldest Votes. As explained here thanks slhck : Only processes with an effective user ID equal to the user ID of the file or with appropriate privileges may change the ownership of a file.

For example: If a system has disk quotas enabled, Alice could create a world-writable file under a directory accessible only by her so no one else could access that world-writable file in the directoryand then run chown to make that file owned by another user Bill.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Server Fault is a question and answer site for system and network administrators.

It only takes a minute to sign up. I try to chown the owner of a file to root, but I can't. I'm doing this as root. I get the following message:. Is the fs mounted as ro readonly? Every "guess" made by other answers is possible. A debugging hint may be to do a strace of the command, and look into the output in order to see what is the real problem in the syscalls itself.

Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered. Chown operation not permitted for root Ask Question.

Asked 10 years, 7 months ago. Active 2 years, 10 months ago. Viewed 76k times. Peter Stuifzand Peter Stuifzand 2 2 gold badges 6 6 silver badges 10 10 bronze badges. Active Oldest Votes. The immutable attribute may be set on the file. Remove it with chattr -i. Paused until further notice.

Cian Cian 5, 1 1 gold badge 24 24 silver badges 40 40 bronze badges. It was -a.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Super User is a question and answer site for computer enthusiasts and power users.

It only takes a minute to sign up. I don't understand why it doesn't allow me to chown file that I own without su privileges.

Subscribe to RSS

Obviously I can use sudo, but I'd like to understand why? Non-privileged users not root cannot chown files to other user names. To use chowna user must have the privileges of the target user. In other words, only root can give a file to another user.

As explained here thanks slhck :. Only processes with an effective user ID equal to the user ID of the file or with appropriate privileges may change the ownership of a file. The reason for this restriction is that giving away a file to another user can allow bad things to happen in uncommon, but still important situations. For example:. Sign up to join this community. The best answers are voted up and rise to the top.

Blender spark ar

Home Questions Tags Users Unanswered. Asked 6 years, 3 months ago. Active 4 years, 4 months ago. Viewed k times. I'm logged in as minime. Active Oldest Votes. As explained here thanks slhck : Only processes with an effective user ID equal to the user ID of the file or with appropriate privileges may change the ownership of a file.

For example: If a system has disk quotas enabled, Alice could create a world-writable file under a directory accessible only by her so no one else could access that world-writable file in the directoryand then run chown to make that file owned by another user Bill. The file would then count under Bill's disk quota even though only Alice can use the file.

Force quit windows 10 shortcut

If Alice gives away a file to Bill, there is no trace that Bill didn't create that file. This can be a problem if the file contains illegal or otherwise compromising data.

Some programs require that their input file belongs to a particular user in order to authenticate a request for example, the file contains some instructions that the program will perform on behalf of that user.

This is usually not a secure design, because even if Bill created a file containing syntactically correct instructions, he might not have intended to execute them at this particular time. Nonetheless, allowing Alice to create a file with arbitrary content and have it taken as input from Bill can only make things worse.

Also: pubs.

Azure files share

Thanks slhck I checked the man page and could not find an explicit mention of this, answer updated. SandroDzneladze nope, you need to have the same user ID as the user you want to chown to.

Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Cryptocurrency-Based Life Forms. Q2 Community Roadmap. Featured on Meta.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I am working on a raspberry pi and am having a tough time giving permissions to an external hard drive that I have mounted using the following tutorial:.

I have now created folders on that external hard drive and when I do a ls -l command I get the following returned:. Now I'm trying to give it all write read and execute permissions or even change the owner and group to pi:pi. However, chmod is not working — it doesn't return an error, just seems to have no effect. This is a linux question but I think someone with background and knowledge of using a raspberry pi can help me out here.

The reason is because the ownership and permissions are defined at mount time for the vfat FS.

Bgfx instancing

Only do this if you're not accessing the the external hard drive from a windows computer:. You can find tutorials for doing this on the web. Learn more. Asked 5 years, 7 months ago. Active 2 years, 8 months ago. Viewed 45k times. Either that, or it is mounted read-only. To the OP: what is the mountpoint? VFAT ist is. VFAT does not support ownership. Active Oldest Votes. Manual page mount 8 : Mount options for fat.

Default: the uid and gid of the current process. The default is the umask of the current process. The value is given in octal. Let us continue this discussion in chat. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up. I try to chown the owner of a file to root, but I can't. I'm doing this as root. I get the following message:. Is the fs mounted as ro readonly? Every "guess" made by other answers is possible.

Hollywood extramovies

A debugging hint may be to do a strace of the command, and look into the output in order to see what is the real problem in the syscalls itself. Sign up to join this community. The best answers are voted up and rise to the top.

Subscribe to RSS

Home Questions Tags Users Unanswered. Chown operation not permitted for root Ask Question. Asked 10 years, 7 months ago. Active 2 years, 10 months ago. Viewed 77k times. Peter Stuifzand Peter Stuifzand 2 2 gold badges 6 6 silver badges 10 10 bronze badges.

Active Oldest Votes. The immutable attribute may be set on the file. Remove it with chattr -i. Paused until further notice. Cian Cian 5, 1 1 gold badge 24 24 silver badges 40 40 bronze badges.

It was -a. But thanks for the nod in the right direction. Thank you, How can I set immutable attribute on it again? Several solution exists, some among them: you have a filesystem does not lets you eg. Filesystem is ext3, mounted read-write, No SELinux. These place restrictions even on what root can do. The file is on a file system that does not support file ownership, such as V FAT.

lchown operation not permitted

Lucas Kauffman Mukesh Mukesh. I had same problem. The problem is my system was hacked and some files were replaced. Now I want to replace them with the originals but I doesn't work. If your system was hacked, then you don't want to put files back.


thoughts on “Lchown operation not permitted

Leave a Reply

Your email address will not be published. Required fields are marked *