I followed these instructions to build Shadow, which provides the groupadd command. I am now getting an error when trying this:

$ groupadd automake1.10
groupadd: 'automake1.10' is not a valid group name

I checked alphanumeric names, and they work okay.


See the source code, specifically libmisc/chkname.c. Shadow is pretty conservative: names must match the regexp [_a-z][-0-9_a-z]*\$? and may be at most GROUP_NAME_MAX_LENGTH characters long (configure option, default 16; user names can usually go up to 32 characters, subject to compile-time determination).

Debian relaxes the check a lot. As of squeeze, anything but whitespace and : is allowed. See bug #264879 and bug #377844.

POSIX requires allowing letters of either case, digits and ._- (like in file names). POSIX doesn't set any restriction if you don't care about portability. A number of recommended restrictions come from usage:

  • Colons, newlines and nulls are right out; you just can't use them in /etc/passwd or /etc/group.
  • An name consisting solely of digits is a bad idea — chown and chgrp are supposed to treat a digit sequence as a name if it's in the user/group database, but other applications may treat any number as a numerical id.
  • An initial - or a . in a user name is strongly not recommended, because many applications expect to be able to pass $user.$group to an external utility (e.g. chown $user.$group /path/to/file)¹. A . in a group name should cause less trouble, but I'd still recommend against it.
  • / is likely to cause trouble too, because some programs expect to be able to use user names in file names.
  • Any character that the shell would expand is probably risky.
  • Non-ASCII characters should be ok if you don't care about sharing with systems that may use different encodings.

¹ All modern implementations expect chown $user:$group, but support chown $user.$group for backward compatibility, and there are too many applications out there that pass a dot to remove that compatibility support.

  • Re chown argument: the current syntax, at least in GNU coreutils, is user:group, with dot being accepted only for compatibility. One can use j.smith:j.smith. – grawity Apr 17 '11 at 10:03
  • 1
    @grawity: It's not just GNU coreutils, but the problem isn't chown itself, it's existing scripts and other programs that call chown $user.$group instead of chown $user:$group — even if the chown implementation tries to do the right thing, some cases are intrinsically ambiguous. – Gilles Apr 17 '11 at 11:58

If you're feeling adventurous, you can edit /etc/group directly and put in whatever group name you like. Also, this has the added bonus that when you encounter one of the problems @Gilles mentioned, you may not be able to load an editor to fix the problem, or even log in at all - giving you valuable experience in recovering a broken system!

  • 4
    Don't forget to edit /etc/gshadow when adding groups. Also, use vigr(8) rather than directly editing the files. – camh Apr 17 '11 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.