Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 27
    hysterical raisins? Commented Apr 10, 2016 at 5:18
  • 2
    Didn't work for me. But this did: getent passwd | grep "$USER" | cut -d":" -f5 | cut -d"," -f1 Commented May 24, 2016 at 0:48
  • 2
    Use grep "^$USER:" or getent passwd $USER to not match all usernames containing the name of the current user Commented Jul 22, 2016 at 16:13
  • 1
    Great answer. Here's another one-liner based on your answer that's suitable to insert somewhere in eg. /etc/profile.d export FULL_USER_NAME="$(getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1)" Commented Jun 20, 2023 at 1:39