How can I log all login history until now? By "all" I mean all users: admin, guests, and every other user.
I am using MacOS HighSierra.
In Terminal, use the last
command.
Also, read the manual page for last
, in Terminal: man last
last
in the terminal on El Capitan, the only output I get is wtmp begins Mon Oct 25 16:40
, or 5 mins later wtmp begins Mon Oct 25 16:45
. The man page says: "If no users, hostnames or terminals are specified, last prints a record of all logins and logouts."
Oct 25, 2021 at 5:49
last
command is working as stated in its manual page and shows my current login and other previous ones along with reboot and shutdown times.
Oct 25, 2021 at 12:28
Checked on Mac OS Mojave 10.14.5
sudo log show --style syslog --last 30m | awk '/Enter/ && /unlockUIBecomesActive/ {print $1 " " $2}'
The above no longer works in macOS Sonoma, but this seems to:
sudo log show --style syslog --last 1d | awk '/CA sending unlock success to dispatch/ {print $1 " " $2}'
last
which catches both.
--predicate
, something like --predicate 'eventMessage contains …'
?
last
command is the accepted answer and provides user names. In addition to the issues @Prado mentioned, this solution doesn't show the user name. I doubt the poster was looking for just a list of times when logins occurred with no reference to the username.
Aug 29, 2019 at 18:57
last
is a specific command from UNIX/BSD just for that purpose, we can trust its results, logger can be rewritten and it not reliable for such thing, unless previously configured for longer data storage. I prefer last
also for this reason.
log show --style syslog --last 30m --predicate 'eventMessage CONTAINS "unlockUIBecomesActive"' --info
Can also use
log show --style syslog --start "YYYY-MM-DD hh:mm:ss" --end "YYYY-MM-DD hh:mm:ss" --predicate 'eventMessage CONTAINS "unlockUIBecomesActive"' --info
etc.