chown 指令中點(".", dot)的用法
Nov 17, 2020
最近看到同事在寫 dockerfile 時,寫到:
chown apuser.apuser -R /data
一直覺得那個"點"很奇怪XD
後來查了一下才發現那個寫法已經不正確了,只為了向下相容,所以目前還支援,正確的寫法要改成:
chown apuser:apuser -R /data
原因:
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 `.'.
ref:
https://unix.stackexchange.com/questions/245210/why-does-a-work-in-chown