Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I know this is possible duplicate but I looked at other answers and wasn't satisfied with the responses. You should be able to use the chown command if you are the super user OR the owner of the file. Well, in my case I am the owner of the file, and I want to use chown. But I want to change ownership of file to super user, so I type following:

$ chown root testfile

But it gives me error:

 chown: changing ownership of `testfile': Operation not permitted

However, I am the owner of the file, and granted myself read, write, and execute permission on the file:

-rwx------  1 viggy viggy      10 Nov 14 13:01 testfile

So as the owner of the file, why can I not change ownership of the file?

share|improve this question
    
Even if you are not satisfied with the answers, a duplicate is a duplicate. The aim is to get all information in 1 question, not make new dupes –  Nanne Nov 15 '12 at 8:03
    
possible duplicate of chown: changing ownership of `...': Operation not permitted –  Anwar Shah Nov 15 '12 at 12:53
add comment

1 Answer 1

up vote 2 down vote accepted

You need to be root to change the ownership of a file. Ordinary users can't do that.

Otherwise it would be easy to get a root access by just using chmod to set the SETUID bit and then changing the ownership to root.

share|improve this answer
    
So the Ubuntu documentation is wrong when it says you can use chown if you are the super user OR the owner of the file. Apparently, being the owner doesn't suffice. –  JohnMerlino Nov 16 '12 at 16:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.