1827207 Members
2764 Online
109716 Solutions
New Discussion

Change owner

 
Cheung_2
Frequent Advisor

Change owner

I found the user can change the file owner on UNIX box , but can't in Linux,
eg. ( On UNIX )
# whoami
UserA
# ll
-rw-rw-rw- userA ACC abc.prn
# chown UserB:ACC abc.prn
#ll
-rw-rw-rw- userB ACC abc.prn

(On Linux)
do the same thing,
# chown UserB:ACC abc.prn
chown: changing ownership of `./abc.prn': Operation not permitted

How to let the user to change the ownership to other ID? Thx.
Andy
4 REPLIES 4
U.SivaKumar_2
Honored Contributor

Re: Change owner

Hi ,

only root is empowered to use chown command in that way.

regards,

U.SivaKumar
Innovations are made when conventions are broken
Tom Geudens
Honored Contributor

Re: Change owner

Hi,
You can indeed not "by default" do this on Linux, but you can make it equal to the Unix box by using sudo.
Important note : Unless you want everyone to be able to chown every file (not good !) you should specify this user by user and use the
"chown --from=CURRENT_USER" commandline to make sure the user can only chown his/her own files.

Regards,
Tom
A life ? Cool ! Where can I download one of those from ?
Steven Mertens
Trusted Contributor

Re: Change owner

hi,

It's a restriction on kernel level. But there's a way to circumvent this by compiling your own kernel. Before you do that you must change the following file in the kernel source tree (/usr/src/linux normally, if installed)

include/kernel/capability.h

Search in the file for the following line and change the 0 into a 1.

#define CAP_CHOWN 0

rgds.

Steven

Kelli Ward
Trusted Contributor

Re: Change owner

Hi,
Another agreement.
UserA can't take ownership.
UserB or root can only give ownership.
You can, as UserA, cp the file and get a copy with you as the owner.

Good Luck,

Kel
The more I learn, the more I realize how much more I have to learn. Isn't it GREAT!