
To be able to change the group owner to admin, Ben must be a member of the admin user group. Now Ben wants to change the group owner to admin user group. The file1.txt is owned by the user Ben and Ben’s primary user group. The user must be a member of the new group.įor Example, let’s think user Ben wants to change the group owner of the file1.txt.The user must own the File or the Directory.Which means, A Linux user may change the group owner of a file if following two conditions are satisfied: Changing the Group OwnerĪ 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. Note that to run Linux commands with sudo privileges, you need to be a member of the sudo admin group. So you have to run the chown command as the root user or you can run the chown command with sudo. Only the root user or a user with root privileges may change the owner of the file. The bottom line is that regular Linux users don’t have permissions to change the file owner even as the owner of the file. Instead of changing the owner, chown command output the following error:Ĭhown: changing ownership of ‘file1.txt’: Operation not permitted Solution Now I will run the chown command and try to change the file owner to root. In the home directory I have a text file called file1.txt which is owned by the user ben. The way Linux file permissions work, you cannot give away the ownership of a file or folder you own.įor example, I have logged into my Ubuntu Linux system as the user ben. Only the root user can change the file owner or you need have sudo privileges as a regular user. A Linux user cannot change the ownership of a file even if the user owns the file. But can you change the ownership of a file or directory that you own? Chown operation not permitted when changing the file owner in LinuxĪs a Linux user, you can change the permissions of a file or directory you own.
