Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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.

share|improve this answer

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

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

share|improve this answer
up vote 1 down vote accepted

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

The magic command is loginctl (systemd).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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