How do I look up my full user name in Ubuntu? I want this information to propagate to the environment variables
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.
getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1 Gert van Dijk
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
But really, for use in Git for a single user do:
git config --global user.name "Your Full Name" git config --global user.email "email@example.com"