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?
Asked
Active
Viewed 167 times
1
ManuelSchneid3r
- 4,256
- 8
- 41
- 58
-
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 09 '13 at 13:23
3 Answers
4
What about the commands users and last.
users
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
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.
slm
- 363,520
- 117
- 767
- 871
1
You could use the auth-log for getting this information.
Example for CentOS5: aureport -l another possibility is using the last command.
Nils
- 18,202
- 11
- 46
- 82
1
All those command do not track users that don't use a TTY.
The magic command is loginctl (systemd).
Stephen Ostermiller
- 982
- 2
- 11
- 27
ManuelSchneid3r
- 4,256
- 8
- 41
- 58