Change the owner of a file

Asked by peter

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:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

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.

Revision history for this message
Ralph Corderoy (ralph-inputplus) said :
#2

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.

Revision history for this message
peter (peter-neuweiler) said :
#3

Thanks.
Peter