Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

How do I look up my full user name in Ubuntu? I want this information to propagate to the environment variables GIT_AUTHOR_NAME and GIT_COMMITTER_EMAIL.

share|improve this question
What do you mean by full user name? – Symin Feb 2 '13 at 12:05
Like "Peter Jackson" instead of, say, the variable USER set to pejack. – Nordlöw Feb 2 '13 at 12:08
It's often nicer to see full names in commit logs. – Nordlöw Feb 2 '13 at 12:10
up vote 6 down vote accepted

These fields in the /etc/passwd file are called GECOS fields. Unfortunately, I cannot find a single command to get this single field such as the full name. I believe this cannot be done without using shell scripting. Below are two approaches.

  • Parse passwd directly:

    getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1
    Gert van Dijk
  • Use of finger

    finger -m $USER | head -n 1 | sed 's/\(.*\)Name\:\s\(.*\)$/\2/g'
    Gert van Dijk

Related question on SO: What's the easiest way to get a user's full name on a Linux/POSIX system?

For programming in C, this is more elegant by using getpwnam().

But really, for use in Git for a single user do:

git config --global "Your Full Name"
git config --global "user@example.tld"
share|improve this answer

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.