man chown gives description and usage and other useful info on
chown - change file owner and group
chown [OPTION]... [OWNER][:[GROUP]] FILE...
chown [OPTION]... --reference=RFILE FILE...
Form the info given by man page, we may know that
chown $USER:$USER changes owner and group of target file to
chown $USER only changes owner of target file to
$USER, leaving group of the target file unchanged.
Details (from man page) follow:
Owner is unchanged if missing. Group is unchanged if missing, but changed to
login group if implied by a ':' following a symbolic OWNER. OWNER and GROUP may
be numeric as well as symbolic.
chown $USER:$USER can be shortened as
root root from
namei -l command mean that the owner and group of that file are both set to
root. That's not owner defined or listed twice. Owner and group are two related but different concepts. And a file always has a owner and a group.
As to use
chown command, great chances are superuser privilege is required, since one is likely to transfer the ownship of a file when using
chown command. However, that is not always the truth.
Say, we have a user named 'test', who belongs to several groups.
id command gives following output:
uid=1000(test) gid=1000(test) groups=1000(test),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),110(sambashare)
And user 'test' owns the following file:
-rw-r--r-- 1 test test 0 May 27 23:34 test_file
Then we can change the group of
sambashare without superuser privilege, as user 'test' belongs to 'test' group and 'sambashare' group at the same time, user 'test' already owns enough permission to change the group of the file.