cancel
Showing results for 
Search instead for 
Did you mean: 

chown question

SOLVED
Go to solution
Pattabhi
Frequent Advisor

chown question

Gurus,

I am not able to change the ownership of a file that is owned by me to a different id. I go to /tmp create a file and then try to change the ownership by "chown" command and it says operation not permitted/not owner.

I see thi speculiar behavious only on Linux and Solaris but not on HPUX. ould nay one have an idea what is happening here?

Below exampe might give you a good idea

[ssriniva@marple ~]$ pwd
/home/ssriniva
[ssriniva@marple ~]$ id
uid=1807(ssriniva) gid=500(support) groups=500(support)
[ssriniva@marple ~]$ touch aaa
[ssriniva@marple ~]$ ls -ld aaa
-rw-r--r-- 1 ssriniva support 0 Oct 3 2007 aaa
[ssriniva@marple ~]$ chown praman1 aaa
chown: changing ownership of `aaa': Operation not permitted
[ssriniva@marple ~]$
7 REPLIES
TY 007
Honored Contributor

Re: chown question

Hello Pattabhi,

>> behavious only on Linux
>> but not on HPUX
>> have an idea what is happening here

>> [ssriniva@marple ~]$ chown praman1 aaa
>> chown: changing ownership of `aaa': Operation not permitted

Try: [ssriniva@marple ~]$ chown ssriniva aaa
--> No Error

For Linux, may require root to change file owner to other owner.

You can try to install GNU core utilities in HP-UX OS & compare:
http://hpux.cs.utah.edu/hppd/hpux/Gnu/coreutils-6.9/

[HP-UX] $ /usr/local/coreutils/bin/chown praman1 aaa

Thanks
Pattabhi
Frequent Advisor

Re: chown question

It works with core utils

[56] % cd /tmp
[57] % ls -ld a
-rw-r----- 1 praman1 support 0 Oct 3 13:01 a
[58] % id
uid=1500(praman1) gid=500(support)
[59] % /usr/local/coreutils/bin/chown reproadm a
[60] % ls -ld a
-rw-r----- 1 reproadm support 0 Oct 3 13:01 a
[61] %



and even chown ssriniva aaa also works
Pattabhi
Frequent Advisor

Re: chown question

I have seen this behaviour on Linux,Solaris and AIX but on HPUX it works fine..
TY 007
Honored Contributor
Solution

Re: chown question

Hello,

[root@marple ~]# chmod 4755 /bin/chown

[sriniva@marple ~]$ chown praman1 aaa

Possible the earlier result is expected as per design?

Thanks
Pattabhi
Frequent Advisor

Re: chown question

Thanks Mate... So i can infer that it is as per design in Linux,Solaris and AIX and if you have to make it work u need to set the "set-uid" option.


REgards,
Pattabhi Raman
Philip Gunter
Respected Contributor

Re: chown question

I'd be very careful with that last suggestion. That will allow anyone on the system to chown any file.

The behaviour that you're seeing is by design on Linux/Solaris/AIX - allowing file giveaways is a bad thing.

On HP-UX it is enabled by default. Have a look at getprivgrp/setprivgrp

Cheers,
Philip.
Pattabhi
Frequent Advisor

Re: chown question

Thanks for the pointers mate.

Regards,
Pattabhi RAman