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

前端 未结 10 1571
旧时难觅i
旧时难觅i 2021-01-31 08:29

I could grep through /etc/passwd but that seems onerous. \'finger\' isn\'t installed and I\'d like to avoid that dependency. This is for a program so it would be nice if there

10条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-31 08:43

    Combination of other answers, tested on minimal Debian/Ubuntu installations:

    getent passwd `whoami` | cut -d ':' -f 5 | cut -d ',' -f 1
    

提交回复
热议问题