[sf-lug] 501 and other anomolies [getpwuid(3), etc.]

Michael Paoli Michael.Paoli at cal.berkeley.edu
Sat Mar 24 15:45:58 PDT 2007

P.S. And, e.g. last(1) and who(1) will truncate display of the login
name to 8 characters (at least they do on sf-lug.com. apparently running
CentOS release 4.4 (Final)) - that could lead to rather abiguous output
results for login names that matched in the first 8 characters, but
were otherwise distinct.
mpaoli at sf-lug ~ 303$ perl -e 'print(scalar(getpwuid(501)),"\n");'
mpaoli at sf-lug ~ 304$ 

(sending to sf-lug at linuxmafia.com again ...)

Date: Fri, 23 Mar 2007 20:36:34 -0800
From: Michael Paoli <Michael.Paoli at cal.berkeley.edu>
To: Jim Stockford <jim.stockford at gmail.com>
Cc: sf-lug at linuxmafia.com
Subject: Re: [sf-lug] 501 and other anomolies [getpwuid(3), etc.]

The operating system typically uses getpwuid(3) to convert from
UID to login name.  If that fails (and/or perhaps if it's too long)
the program will generally just use the UID (or possibly truncate the

For backwards compatibility (at least back through UNIX 7th edition,
circa 1979) login and group names should be composed as follows:
first character a lowercase ASCII letter
remaining characters lowercase ASCII letters and/or
ASCII decimal digits
minimum length of 3 characters, maximum of 8

Most current SUS (nee POSIX) specifications relax those requirements
a bit, but if one's within the bounds of the most current specifications,
but exceeding those older and long-standing limits, one may run into
problems (/bugs) with software that hasn't been suitably updated (i.e. if
you want to play it safe, stay within the older requirements, if you want
to torture-test software and see what bugs it may have, push (or exceed) the
limits of the most current specifications).

Also, the operating system may state which version(s) of which
specification(s) it is mostly or entirely compliant with (whether
or not fully certified or tested against such).

UNIX is trademarked, ... anything that officially certifies against
sufficiently current SUS (or did so earlier) can be called UNIX.
LINUX is (technically) "just" a kernel ... though operating systems
running a LINUX kernel are typically termed "LINUX" operating systems.
Note that some LINUX distributions also support non-LINUX kernels,
e.g. there's not only Debian GNU/Linux, but also Debian GNU/Hurd.


Quoting Jim Stockford:

> on another, similar, system the ls -l command
> displays a nine-character user name.
> echo -n jstockford | wc
> shows 10 characters.
> So i'm guessing the max is nine. I'll confirm on
> the sf-lug.com box.
> On 3/23/07, Jim Stockford <jim.stockford at gmail.com> wrote:
> >
> >
> > I log into the sf-lug.com machine (you can too,
> > if you ask for a shell account) and run ps aux
> > and see that user 501 is running a bash shell.
> >
> > Well, 501--that's me! I use the command
> > tail -20 /etc/passwd
> > and see jstockford has UID 501 and GID 501.
> >
> > The way things are supposed to work is that
> > "internally", the system uses numbers, but
> > when it prints information to standard out, it
> > converts the number to the user's login name.
> >
> > Things aren't working that way.
> >
> > Why?
> >
> > jim

More information about the sf-lug mailing list