Why the modern chown command uses a colon to separate the user and group
In the beginning, all
chown(1) did was change the owner of a file;
if you wanted to change a file's group too, you had to use
as well. This is actually more unusual than I realized before I started
to write this entry, because even in V7 Unix the
chown(2) system call
itself could change both user and group, per the V7
chown(1) to only changing the owner did make the command
pretty simple, though.
By the time of 4.1c BSD,
chown(1) had become
because, per the manual page:
Only the super-user can change owner,
in order to simplify as yet unimplemented accounting procedures.
(The System V line of Unixes would retain an unrestricted
system call for some time and thus I believe they kept the
command in section 1, for general commands anyone could use.)
In 4.3 BSD, someone decided that
chown(8) might as well let you change
the group at the same time, to match the system call. As the manual page
covers, they used this syntax:
/etc/chown [ -f -R ] owner[.group] file ...
That is, to chown a file to user
staff, you did
chown cks.staff file'.
This augmented version of the
chown command was picked up by various
Unixes that descended from 4.x BSD, although not immediately (like many
things from 4.3 BSD, it took a while to propagate around). Sometimes
this was the primary version of
chown, found in
/usr/bin or the
like; sometimes this was a compatibility version, in
through fairly late, for example). Depending on how you set up your
$PATH on such systems, you could wind up using this version of
and thus get used to having 'user:group' rejected as an error.
Then, when it came time for POSIX to standardize this, someone woke
up and created the modern syntax for changing both owner and group
at once. As seen in the Single Unix Specification for
this is '
chown owner[:group] file', ie the separator is now a
colon. Since POSIX and the SUS normally standardized existing
practice (where it actually existed), you might wonder why they
changed it. The answer is simple: a colon is not a valid character
in a login, while a dot is.
Sure, dots are unusual in Unix logins in most places, but they're
legal and they do show up in some environments (and they're legal
in group names as well). Colons are outright illegal unless you
like explosions, fundamentally because they're the field separator
/etc/group. The SUS manpage
actually has an explicit discussion of this in the RATIONALE section,
although it doesn't tell you what it means by 'historical
(The SUS manpage also discusses a scenario where using
chgrp separately isn't sufficient, and you have to make the change
in a single
chown() system call.)
PS: Since I think I ran into this dot-versus-colon issue on our
old Solaris 10 fileservers, I
/usr/bin in my
$PATH there. I
generally prefer UCB versions of things to the stock Solaris versions,
but in this case it tripped me up.
PPS: It turns out the GNU chown accepts the dot form as well provided that it's unambiguous, although this is covered only in the chown info file, and is not mentioned in the normal manpage.
Comments on this page:Written on 05 April 2017.