You may have used
chown command to change the ownership of files or directories like below.
$ ls -l file -rw-r--r-- 1 root root 675 2013-09-23 23:23 file $ sudo chown foo file $ ls -l file -rw-r--r-- 1 foo root 675 2013-09-23 23:23 file
But this is not good because group of
file is still
root. Most case, you want to set it the default(login) group of the user.
$ id foo uid=1010(foo) gid=1009(foo) groups=1009(foo)
In this case, you want to set it
foo. For that, I used a command below.
$ chown foo:foo file $ ls -l file -rw-r--r-- 1 foo foo 675 2013-09-23 23:23 file
Not bad. But you have to know the default group of the user. It is not always same as the user name.
So, here is the best way. Just add
: after the user name.
$ sudo chown foo: file $ ls -l file -rw-r--r-- 1 foo foo 675 2013-09-23 23:23 file
Wow! This is super easy. See also
… If a colon but no group name follows the user name, that user is made the owner of the files and the group of the files is changed to that user's login group. …