# how to get real user name

**URL:** <https://community.unix.com/t/how-to-get-real-user-name/173801>\
**Category:** Shell Programming and Scripting\
**Created:** [August 1, 2007, 3:10pm UTC](https://community.unix.com/t/how-to-get-real-user-name/173801 "2007-08-01T15:10:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aga](https://community.unix.com/letter_avatar/aga/32/6_22734026db12803ebb3e059622ac3534.png) [@aga](https://community.unix.com/u/aga)\
**Post date:** [August 1, 2007, 3:10pm UTC](https://community.unix.com/t/how-to-get-real-user-name/173801/1 "2007-08-01T15:10:05Z")

</div>

I know that in order to get a real user name I should use the following command: cut -d: -f5 /etc/passwd. But how can I get the real user name for those users who are currently logged in to the system??? 😕 Can somebody help me???

---

<div class="post-metadata">

**Author:** ![hemangjani](https://community.unix.com/letter_avatar/hemangjani/32/6_22734026db12803ebb3e059622ac3534.png) [@hemangjani](https://community.unix.com/u/hemangjani)\
**Post date:** [August 1, 2007, 3:29pm UTC](https://community.unix.com/t/how-to-get-real-user-name/173801/2 "2007-08-01T15:29:15Z")

</div>

who | awk -F' ' '{ print $1 }' | sort | uniq \> list2; while read record; do cat /etc/passwd | grep $record | cut -d: -f5; done \< list2; rm list2

🙂

---

<div class="post-metadata">

**Author:** ![Shell\_Life](https://community.unix.com/user_avatar/community.unix.com/shell_life/32/521_2.png) [@Shell\_Life](https://community.unix.com/u/Shell_Life)\
**Post date:** [August 1, 2007, 3:51pm UTC](https://community.unix.com/t/how-to-get-real-user-name/173801/3 "2007-08-01T15:51:37Z")

</div>

This will give you more information of who is logged in -- just cut what you need:

```nohighlight
finger -fs `who -q | egrep -v '# users'`

```

---

<div class="post-metadata">

**Author:** ![aga](https://community.unix.com/letter_avatar/aga/32/6_22734026db12803ebb3e059622ac3534.png) [@aga](https://community.unix.com/u/aga)\
**Post date:** [August 1, 2007, 4:07pm UTC](https://community.unix.com/t/how-to-get-real-user-name/173801/4 "2007-08-01T16:07:12Z")

</div>

Thanks for your hint but is it possible to do this without using the 'awk' command???
