Change the owner of a file

Asked by peter on 2011-04-05

Hi

I have a file and I would change the user of this file.

How can I do this? Thanks.
Peter

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu bash Edit question
Assignee:
No assignee Edit question
Solved by:
peter
Solved:
2011-04-06
Last query:
2011-04-06
Last reply:
2011-04-05

you can use chown

sudo chown newuser:newuser /path/to/filename

Will do it. If the file is owned by the user running it then sudo isn't needed.

To clarify, the above is changing the owner and group of the file at the same time. "sudo chown newo:newg foo" changes foo's owner and group to newo and newg. Plain "sudo chown newo foo" would change just the owner. On Ubuntu, each user has a group of their own too and it's called the same thing, so user "tom" can set both with "sudo chown tom:tom foo" which is why "newuser" appears twice in the above; one of them is a group rather than an owner.

peter (peter-neuweiler) said : #3

Thanks.
Peter