LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-07-2009, 04:14 AM   #1
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
chown cannot change owner


I have a scenarion where I am user "A" on a Linux machine. There is another user "B" on this machine. I created a file in my home directory and tried to change the ownership to "B".

In this case I get the Operation not permitted error.

Up to my understanding this seems to me as a security issues that linux is not allowing the file to owned by user B.

Am I correct ? Is there anyway to achieve it except becoming a super user or suoders.
 
Old 07-07-2009, 04:23 AM   #2
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
You need to be root to change ownership of files. Unfortunately there's no solution other than to log in as root or using sudo (if it is configured correctly).

Last edited by vharishankar; 07-07-2009 at 04:56 AM. Reason: grossly misleading error rectified
 
Old 07-07-2009, 04:27 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You need root permissions to change a file's owner. You can change the group ownership if you are a member.

If you copy a file from another directory, to your own, it will inherit your ownership. (If you have read rights)
 
Old 07-07-2009, 04:35 AM   #4
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Original Poster
Rep: Reputation: 58
Harishankar in my scenario user A is the owner of the file and user A want to change the owner to user B.
 
Old 07-07-2009, 04:37 AM   #5
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
Quote:
Originally Posted by PMP View Post
Harishankar in my scenario user A is the owner of the file and user A want to change the owner to user B.
That's still not possible except as root. chown requires root permissions except to change group.

The reason for not allowing changing your own file ownership is because you could easily write a malicious script (just an example, nothing personal) and use it to access another user's files. Since that script is "owned" by the other user, it would have the permissions to scan the other user's home directories and access personal information etc.

Last edited by vharishankar; 07-07-2009 at 04:46 AM.
 
Old 07-07-2009, 04:49 AM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by harishankar View Post
That's still not possible except as root. chown requires root permissions except to change group.
That's corrrrect, and your first post is still wrong.
Quote:
You need to be root to change ownership of files you don't own.
He owns the file (before a chown, anyway), and can't change its
ownership. The rationale (to the best of my knowledge) behind
this (the fact that one can't "disown" oneself of a file) is
stemmed from systems with multiple users and user quotas; one
could (if disowning was possible) if one was about to run out
of space just make some files in an arbitrary place in the
file-system where one happens to have write access files and
make someone else the owner (who probably will never stumble
across those, so the ownership doesn't matter too much as
long as the group permissions are still fine).



Cheers,
Tink
 
Old 07-07-2009, 04:56 AM   #7
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
Sorry I made a mistake. Grossly misleading. A quick look at google confirms that most *nix implements chown that way. But there seem to be ways to bypass this behaviour on some distributions/OSes(use google, I won't help )

Last edited by vharishankar; 07-07-2009 at 04:58 AM.
 
  


Reply

Tags
chown, permitted



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can't change owner of directory miner49er Linux - Networking 1 05-04-2006 03:58 PM
Change Owner on many files how to? linchat Linux - General 2 02-23-2006 04:14 PM
Change owner arubin Linux - Newbie 3 04-30-2004 12:23 PM
CHOWN as root fails; owner 4294967295? eventide Linux - Hardware 1 11-24-2003 12:42 AM
Change owner juno Linux - General 3 01-08-2003 07:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:44 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration