GNU Emacs Lisp Reference Manual
LOGNAME is set, that value is used. Otherwise, if the environment variable USER is set, that value is used. Otherwise, the value is based on the effective UID, not the real UID. If you specify uid, the value is the user name that corresponds to uid (which should be an integer).
(user-login-name)
=> "lewis"
LOGNAME and USER.(user-full-name)
=> "Bil Lewis"
The symbols user-login-name, user-real-login-name and user-full-name are variables as well as functions. The functions return the same values that the variables hold. These variables allow you to ``fake out'' Emacs by telling the functions what to return. The variables are also useful for constructing frame titles (see Frame Titles).
(user-real-uid)
=> 19