5

I am aware that the /etc/passwd file consists of rows of user accounts that comprise of 7 fields namely;

username:encrypted password or token:userid:groupid:gecos:home directory:default shell 

however the details of a few users appears as

username:x:1000:1000:username,,,:/home/username:/bin/bash

What do the commas represent?

EDIT

Further to Daniel's comment below - The reason I ask why the commas appear is because no other user account in the /etc/passwd appears to have the same structure despite not having the other details of the gecos field.

2 Answers2

6

The Gecos field consists not only of the username, but also information about that user, f.e.:

  • Realname
  • Room-Number
  • Phone-Number
  • and so on...

If we look at the example of the Wikipedia article, this becomes clear:

jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8910,(234)555-0044,email:/home/jsmith:/bin/sh

The fifth field, called the Gecos field, is commentary that describes the person or account. Typically, this is a set of comma-separated values including the user's full name and contact details.

So what you're seeing is an empty set of user information. It most likely varies from system to system how those informations are handled and set in the passwd file.

Bobby
  • 9,032
1

As said in the comments to the original question: Why are there weird commas in my /etc/passwd file? and http://en.wikipedia.org/wiki/Gecos_field explain what these fields are.

To answer the question "why do they appear for some users and not others": this information is usually created by the tool that adds the user to the system. It does not make sense to have e.g. "Room number" for e.g. the sshd user, and thus these fields are left out by the process creating these users.

But why then do I see e.g.

mysql:x:107:109:MySQL Server,,,:/var/lib/mysql:/bin/false

in my etc/passwd? This user has probably been created by a script that for convenience have used adduser (present on many common systems) instead of the more low-level useradd tool (I think the naming could have been better), and adduser automatically creates the Gecos place holders. Alternatively it might have been a conscious choice at user creation just to adhere to the Gecos format for conformity, but I believe it is mostly unnecessary cruft in these cases.

Why then are the Gecos fields empty for my regular user as well? Because I simply never filled room number/etc. out when I created that user (I don't even know if I got that choice during system installation - I don't think so).

(On a sidenote: this system means that a full name of for example "Daniel Andersson, PhD" will be wrongly interpreted by most tools.)