by Oliver; 2014
18. chown
chown, less commonly seen than its cousin
chmod, changes the owner of a file.
As an example, suppose
myfile is owned by
root, but you want to grant ownership to
ubuntu (the default user on ubuntu) or
ec2-user (the default user on Amazon Linux).
The syntax is:
$ sudo chown ec2-user myfile
If you want to change both the user to
someuser and the group to
somegroup, use:
$ sudo chown someuser:somegroup myfile
If you want to change the user and group to your current user,
chown works well in combination with
whoami:
$ sudo chown $( whoami ):$( whoami ) myfile
<PREV
NEXT>