Operating System - Linux
1833056 Members
2556 Online
110049 Solutions
New Discussion

Re: GNU chown exits after Operation not permitted

 
Ashok Kumar_6
Occasional Advisor

GNU chown exits after Operation not permitted

Why GNU (Linux AS 3.0) does not allow to change ownership of a file to owner of the user. How can we fix this.
11 REPLIES 11
Steven E. Protter
Exalted Contributor

Re: GNU chown exits after Operation not permitted

There may be a bug. Are you current on fixes and up2date or yum?

pwck
grpck

If those commands exist there may be a problem in the /etc/passwd or /etc/shadow or /etc/group file.

There may be a better message in /var/log/messages or dmesg output.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ashok Kumar_6
Occasional Advisor

Re: GNU chown exits after Operation not permitted

/var/log/messages or dmesg output does not telling me anything regarding this.
==
[root@whdb3 root]# uname -a
Linux whdb3.americas.corp.timex.com 2.4.21-27.0.4.ELsmp #1 SMP Sat Apr 16 18:43:06 EDT 2005 i686 i686 i386 GNU/Linux
[root@whdb3 root]# pwck
user adm: directory /var/adm does not exist
user news: directory /etc/news does not exist
user uucp: directory /var/spool/uucp does not exist
user gopher: directory /var/gopher does not exist
user ident: directory /home/ident does not exist
user pcap: directory /var/arpwatch does not exist
pwck: no changes
[root@whdb3 root]# grpck
[root@whdb3 root]#
Gopi Sekar
Honored Contributor

Re: GNU chown exits after Operation not permitted


which file you are trying to change? is it single file or group of files?

I believe you are trying this as root user, otherwise that is the problem, you have to run chown as root.

Are you running this from some sort of restricted shell?

Hope this helps,
Gopi
Never Never Never Giveup
Ashok Kumar_6
Occasional Advisor

Re: GNU chown exits after Operation not permitted

[akumar@whdb3 tmp]$ ll dfd
-rwxr-xr-x 1 akumar it 8 Sep 1 05:31 dfd
[akumar@whdb3 tmp]$ chown appldwp.dba dfd
chown: changing ownership of `dfd': Operation not permitted
[akumar@whdb3 tmp]$ id
uid=504(akumar) gid=501(it) groups=501(it),0(root)
[akumar@whdb3 tmp]$
========
The above will answer your most of the questions. root is able to run chown, but no one else. even when akumar is a member of root group.
Gopi Sekar
Honored Contributor

Re: GNU chown exits after Operation not permitted


the problem is simple, you need to run the chown as root user only.

changing of any file attributes is allowed only if the file is owned by the user or group (with write permission) or others(write permission is required). otherwise only root is allowed to modify.

Hope this helps,
Gopi
Never Never Never Giveup
Ashok Kumar_6
Occasional Advisor

Re: GNU chown exits after Operation not permitted

Gopi, u didnot read my message completly. the owner of the file is akumar(see ll output) and the current user is akumar only(see id output). I'm not that stupid as u think
Ivan Ferreira
Honored Contributor

Re: GNU chown exits after Operation not permitted

That is a normal behaviour. You cannot use the chown command with any other user besides root.

If you want to share a file, you have two choises:

Create a directory with the right group membership, and set the SGID bit to the directory. Instruct users to create "shared" files there. Make users needing the files members of the same group.

Use SUDO to allow the use of chown command to users on they home directory only.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Gopi Sekar
Honored Contributor

Re: GNU chown exits after Operation not permitted

I know you are not that stupid but still, you can not change ownership files owned by you to some other user id eventhough they are yours.

Hope I am clear to you this time,
Gopi
Never Never Never Giveup
Ashok Kumar_6
Occasional Advisor

Re: GNU chown exits after Operation not permitted

This works on HP-UX, why not in Linux?
Ivan Ferreira
Honored Contributor

Re: GNU chown exits after Operation not permitted

Because with a well planned directory structure and group membership, is not needed.

You should read the User Private Group security scheme used by Linux.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Ashok Kumar_6
Occasional Advisor

Re: GNU chown exits after Operation not permitted

So this is how it will work now. If u can not beat them join them ;). Changed my stretegy according to new constraints.

Thanks to all.