Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

3 Answers 3

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.