2

If I create user khadija with username: khadija, how can I populate the fifth field of /etc/passwd?

mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash

I have not found anything under the useradd man page, and cannot access the Internet in this setup.

Are there any other options apart from editing /etc/passwd manually?

1

Have a look at man usermod it shows the -c option which is used to modify the comment field for an account in /etc/passwd.

example:

usermod -c "raspberry pi user account" pi

To update the comments field for the 'pi' user account.

| improve this answer | |
  • Great thanks. I didn't automatically associate 'user's password file comment field' with what I was looking for. – user Oct 14 '14 at 3:56
  • 1
    All good.. Very often it's just a case of getting the terminology right in order to find what you're looking for. – captcha Oct 14 '14 at 3:58
2

You can edit the field by editing the file, or you can use usermod -c, although nowadays it is called the comment field in man 5 passwd, this was not always the case, it used to be the GECOS field on UNIX, although that name did not reflect the use it had: providing general information.

The proper population is a comma separated list of four (possible empty) strings. You still see this in how some programs create this part of the passwd entry, pre-seeding it with UserName,,,.

The first of those fields should contain the full user name (or program name if used for a daemon etc.); the second the physical location; the third (office) telephone; and the fourth home phone (sometimes telex/fax).

Programs like finger can be used to display a persons information, including the structured contents of that field. I have actually used that feature (with Yellow Pages to get information available on all workstation), before the advent of LDAP and personal address books.

| improve this answer | |

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.