Linux: dot as delimiter between user and group names in chown

To set the user and group of a file in Linux, you can use the following syntax:

# chown user:group file

You might also have seen people using the following:

# chown user.group file

Both syntaxes will work. But you should rather use the first one. Here is what info coreutils ‘chown invocation’ says about it:

Some older scripts may still use ‘.’ in place of the ‘:’ separator. POSIX 1003.1-2001 (*note Standards conformance::) does not require support for that, but for backward compatibility GNU ‘chown’ supports ‘.’ so long as no ambiguity results. New scripts should avoid the use of ‘.’ because it is not portable, and because it has undesirable results if the entire OWNER’.’GROUP happens to identify a user whose name contains ‘.’.

So if your user name or group name contains a dot, it will only work with the colon.

Leave a Reply

Your email address will not be published.