User login "log" on Mac OS X

13

6

Does Mac OS record user logins/logouts?

I'm in a situation where I need to show that a certain user was logged in at a certain time (long story) less than four weeks ago.

Is this recorded at the Mac OS level or Darwin level anywhere?

EDIT: The machine is running Mac OS Leopard (non-server edition).

Justicle

Posted 2009-11-04T04:01:42.557

Reputation: 387

Answers

15

You can try the command last which unless the log has been cleared should have a log right back until the OS was installed. Specifically look for any console entries.

Chealion

Posted 2009-11-04T04:01:42.557

Reputation: 22 932

3This is for shutdown, reboots. How about "lock screens" logins, there is something similar? – Paulo Oliveira – 2016-05-25T11:21:21.040

How to check for lock screen logins? – theonlygusti – 2017-08-21T15:09:13.030

1Sweet! I was right, to. Even sweeter. – Justicle – 2009-11-04T04:32:12.913

10

If you want to look back further than the few weeks that last will show these entries are stored for much longer in the ASL database. To view logins use this command, substituting the name you are searching for, or leave off the | grep insert_username_here to see everyone.

syslog -F raw -k Facility com.apple.system.lastlog | grep insert_username_here

To see logouts use:

syslog -F raw -k Facility com.apple.system.utmpx | grep insert_username_here

To view this more cleanly you could use this, which does not show logins via terminal and will show just the epoch times. You must grep for a username or else the data is meaningless:

syslog -F raw -k Facility com.apple.system.lastlog | grep insert_username_here | grep -v tty | awk '{ print $2 }' | sed -e 's/]//g'

The date is displayed as the epoch time. You can convert that to normal time with http://www.epochconverter.com/

ridogi

Posted 2009-11-04T04:01:42.557

Reputation: 2 787

1Thanks for the tip. FYI I was after "GUI" logins, so this should do the trick as well. – Justicle – 2009-11-05T01:56:14.950