Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the /etc/passwd file on my system, the "comment" field, field 5, is inconsistent in its contents. I thought that I could extract it to get the full name of the user.

fullname=`awk -F: '$1 == name {print $5}' name=$LOGNAME /etc/passwd`

However this returns with $fullname containing a name with 0, 3, or 4 commas following. Exploring the man page (man 5 passwd) provides no details of this field other than describing it as "user name or comment field."

Perhaps there is additional information that is stored along with the user name?

share|improve this question
It is simply a comment field - e.g. this is an example: dbus:x:81:81:System message bus:/:/bin/false. I think the comments associated to a user account when created with useradd or adduser is put here. But I mean, who does that? – user13742 Jan 7 '12 at 22:02
Then it must be my distro which has decided that commas belong there. – TheGeeko61 Jan 7 '12 at 22:07
I have them too. It probably signifies that no comment is associated with the user. – user13742 Jan 7 '12 at 22:09
as mentioned in this answer, there is the finger(1) utility to retrieve information of these fields. – soubunmei Feb 28 '15 at 0:23
up vote 4 down vote accepted

This field is often formatted as a GECOS field, which typically has 4 comma-separated fields for extra information in addition to the user's name, such as phone number, building number, etc.

In all cases I have seen, if the field has a comma, the name is what is before the comma. But I can imagine cases where this is not the case (a name of "Foo Bar, Jr" would break, for instance).

share|improve this answer
Excellent resource! Thank you! It's always a good feeling when one emerges from the darkness of ignorance. Your answer has helped me do this. :) – TheGeeko61 Jan 7 '12 at 22:16
According to the man page for chfn, "The only restriction placed on the contents of the fields is that no control characters may be present, nor any of comma, colon, or equal sign." – TheGeeko61 Jan 8 '12 at 1:25
Interestingly, the University of Cincinnati's browsable man pages is where I discovered that; but I don't see the same caveat in other man page sources... ?? – TheGeeko61 Jan 8 '12 at 1:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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