Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
Duplicate of superuser.com/questions/332804/… . Also, you say "Gecos" yourself: see en.wikipedia.org/wiki/Gecos_field –  Daniel Andersson Apr 12 '12 at 8:18
    
@Daniel Andersson - Thanks. I did see that post and should have clarified my post. The reason I ask why the commas appear is because no other user accounts have them. –  PeanutsMonkey Apr 12 '12 at 18:49

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer
    
Strange that this is not mentioned in man 5 passwd. –  l0b0 Apr 12 '12 at 8:27
    
@l0b0: Yes, interesting. So either that information is missing by accident or indent (f.e. that's deprecated). Might be worth asking someone who knows that. –  Bobby Apr 12 '12 at 8:40
    
@Bobby - Thanks. Why is that no other user has the commas even though none of the information is provided e.g. room number, phone number, etc. –  PeanutsMonkey Apr 12 '12 at 18:52
    
@PeanutsMonkey: Could be because a real name (same as username) was entered. I see that in my own passwd, the "general" users are all entered without commas, but later added users all have those commas. So might be tool dependent. –  Bobby Apr 12 '12 at 20:39
    
@Bobby - Sorry for being a newbie at this in the case of the example I posted the real name is the same as the username and it still displays the commas. When you say general users, what do you mean? Also the user I am referring to is the only user on the device and is the user that was created when Linux was installed. –  PeanutsMonkey Apr 12 '12 at 21:32

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.)

share|improve this answer

Your Answer

 
discard

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.