w, who, id and whoami are excluded, because they only give information about users using a tty. Is there a way to extract the name reliably from KDM?

  • You write "the logged in user" as if Unix were a single-user system. Are you assuming there is only one display, and no remote access? – tripleee Jul 9 '13 at 13:23

What about the commands users and last.


   users - print the user names of users currently logged in to the current host

Makes use of the /var/run/utmp and /var/log/wtmp files.


   last, lastb - show listing of last logged in users

Makes use of the /var/log/wtmp log file. Shows historically the last time a user logged in.


You could use the auth-log for getting this information.

Example for CentOS5: aureport -l another possibility is using the last command.


All those command do not track users that don't use a TTY.

The magic command is loginctl (systemd).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.