LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-01-2010, 07:41 AM   #1
schuurs
Member
 
Registered: Feb 2010
Location: The Netherlands
Distribution: Mint 13 / CENTOS4.6 / RHEL5.x
Posts: 38

Rep: Reputation: 0
chown: changing ownership of `<file>': Operation not permitted


Hello,

I am trying to change the ownership of a file but I get the next message:

chown: changing ownership of `<file>': Operation not permitted

The situation is as follows.

My username: schuurs
My primary group: meten
My secundary group: agi
My home directory is located on server "srmc"


cp <file> /home/agi/library/import/.

ls -l /home/agi/library/import/<file>
-rw-r--r-- 1 schuurs meten ...... <file>



User rights import directory drwxrwxrwx
Owner import directory: agi
Group import directory: agi

Primary group of user agi: meten
Secundary group of user agi: agi
Agi's home directory is located in server "dt"

If I am trying to change the ownership (chown) of the previously copied file to 'agi', I will receive the message that the operation is not permitted.
Next to that, it is possible to change the group (chgrp)of the file to 'agi'.

If I copy the same file to a different user, it is possible to change the ownership.

Does someone has a clue if I am forgetting something?
 
Old 02-01-2010, 08:39 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,557
Blog Entries: 28

Rep: Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178
Is there a "file access control list" (FACL) on the file? The getfacl command can be used to display FACLs.
 
Old 02-01-2010, 04:03 PM   #3
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 547

Rep: Reputation: 115Reputation: 115
Are you doing it as root?
 
Old 02-02-2010, 01:58 AM   #4
schuurs
Member
 
Registered: Feb 2010
Location: The Netherlands
Distribution: Mint 13 / CENTOS4.6 / RHEL5.x
Posts: 38

Original Poster
Rep: Reputation: 0
Dear catkin,
When I execute the getfacl command on the file, Ill get:

schuurs@<hostname>:/home/agi/library/import >> getfacl file
# file: file
# owner: schuurs
# group: meten
user::rw-
group::r--
other::---

Dear Devnull10,
I am not root when I try to change the ownership.
 
Old 02-02-2010, 02:54 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,557
Blog Entries: 28

Rep: Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178
Quote:
Originally Posted by schuurs View Post
schuurs@<hostname>:/home/agi/library/import >> getfacl file
# file: file
# owner: schuurs
# group: meten
user::rw-
group::r--
other::---
That is normal when there are no FACLs. In a recent posting someone mentioned the ls command's -Z option to show any SElinux access restrictions. Can you try that and post back?

Another possibility is that the file is on a read-only file system. Are you able to create or modify files in the same directory as the problem file?
 
Old 02-02-2010, 03:18 AM   #6
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
Only root can change file ownerships. If you copy a file, you are creating a new one. Some *nixes support suid directories where the ownership is changed to that of the directory owner. You can use chgrp if you are member of that group.

You can use setfacl to give permissions to another user. ( The "acl" mount option needs to be used and the filesystem must allow it )

You said that your home directory is on another server, and the prompt seems to indicate you are logged in with ssh or rsh to that system. Is that server Linux?
 
Old 02-02-2010, 01:43 PM   #7
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 547

Rep: Reputation: 115Reputation: 115
As said above, you need to be root. Otherwise you could just create a program, suid it and then chown to root!!
 
Old 02-03-2010, 02:23 AM   #8
schuurs
Member
 
Registered: Feb 2010
Location: The Netherlands
Distribution: Mint 13 / CENTOS4.6 / RHEL5.x
Posts: 38

Original Poster
Rep: Reputation: 0
Dear catkin,

The workstation is using RHEL3.7, SElinux is not existing in this OS.
However, the server on which "agi" is located is using RHEL5. I have to ask the system manager of this server.
I do not know which OS is used by the server where my home disk is located on.

Next to that, I can create and modify files. This means that it is not a read-only file system.

Dear jschiwal,
If only root can change the ownership, why can I change the ownership of a file if I copied it to the location of a different user?
Maybe, this is true on the RHEL5 server and not on servers with an older OS.

My prompt is how I created it, I am not using ssh.
I can use "cd" to walk to the location I need on the "agi" disk.

Dear devnull10,
Your comment sounds logical.
 
Old 02-03-2010, 03:06 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,557
Blog Entries: 28

Rep: Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178
Quote:
Originally Posted by schuurs View Post
If only root can change the ownership, why can I change the ownership of a file if I copied it to the location of a different user?
Because copying creates a new file and the new file is created with your default owner, group and permissions.
 
Old 02-04-2010, 01:47 AM   #10
schuurs
Member
 
Registered: Feb 2010
Location: The Netherlands
Distribution: Mint 13 / CENTOS4.6 / RHEL5.x
Posts: 38

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
Because copying creates a new file and the new file is created with your default owner, group and permissions.
The file on which I am trying to change the ownership is also having my default owner and group permissions.

I checked with the system administrator if SElinux is bugging me. We tried by disabling it for a short moment, but without succes. SElinux is not bugging me.
 
Old 02-04-2010, 01:54 AM   #11
schuurs
Member
 
Registered: Feb 2010
Location: The Netherlands
Distribution: Mint 13 / CENTOS4.6 / RHEL5.x
Posts: 38

Original Poster
Rep: Reputation: 0
Dear devnull10,

Do you know if it is possible to disable the behavior of only let root change the ownership of a file?

The reason is as follows:
A test engineer copies a testprogram to the import directory.
One of the library managers copies the testprogram to one of the testprogram libraries without using logging in as "agi"
this is blocked so that only the persons who are part of the group "agi" can copy a testprogram to one of the libraries.
The end owner of the testprogram should be "agi", not the library manager who copied the testprogram.

This worked when the account of "agi" was still located on an HP-UX system. Now that it is located on a RHEL5 system, it does not work anymore.
 
Old 02-04-2010, 04:10 PM   #12
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 547

Rep: Reputation: 115Reputation: 115
You could use groups, guid and umask or you could use sudo to allow the changing of file permissions. The first is by far the preferred method though - you can do a lot of damage if you change the permissions of a file incorrectly!!
 
Old 02-05-2010, 01:56 AM   #13
schuurs
Member
 
Registered: Feb 2010
Location: The Netherlands
Distribution: Mint 13 / CENTOS4.6 / RHEL5.x
Posts: 38

Original Poster
Rep: Reputation: 0
Dear devnull10,

I agree with you.
It this moment the library permissions are arranged with groups and I think I have to accept the fact that there are differences between the old HP-UX and Linux.
 
Old 02-05-2010, 01:57 AM   #14
schuurs
Member
 
Registered: Feb 2010
Location: The Netherlands
Distribution: Mint 13 / CENTOS4.6 / RHEL5.x
Posts: 38

Original Poster
Rep: Reputation: 0
Dear all,

Thank you for explaining this topping to me.
 
Old 06-26-2013, 06:15 PM   #15
bdemchak
LQ Newbie
 
Registered: Jun 2013
Posts: 1

Rep: Reputation: Disabled
Here's another source of this error ...

Our storage server is a ZFS box, and it cares about which host a root request (e.g., chown) is coming from. If the storage server knows about the host and the host user is logged on as root, the request will execute as expected. If the storage server doesn't know about the host, the host user's root credentials are mapped to anonymous, which causes the "Operation not permitted" message, too.

Solution: get the storage system administrators to add your host as a recognized root user.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
failed to preserve ownership operation not permitted yogks Linux - Software 1 11-27-2008 05:54 PM
chown: Operation not permitted presarioch Linux - Newbie 13 06-22-2008 04:28 PM
Changing ownership 6.4 chown fails. jarin scott Linux From Scratch 6 02-16-2005 05:16 AM


All times are GMT -5. The time now is 09:29 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration