1

The last command in Terminal (on Mac OS X 10.11.2) is supposed to display a list of login history. However, when I type it in, all I get is

user$ last

wtmp begins Mon Jan 11 13:17
user$ last user

wtmp begins Mon Jan 11 13:17
...

The date printed is the current date and time. Is there something wrong with my system? Might it have something to do with the fact that I have a brewed bash 4.3 in /usr/local/bin?

Since last doesn't work, are there any alternatives? I'm trying to write a shell script that can figure out how long it's been since the login before the current session.

  • 1
    sudo last make any difference? – Xen2050 Jan 11 '16 at 20:04
  • Ahh, yes, that did work. I did some research and discovered the problem is that I didn't have read-access to private/var/log/system.log. Thank you! – Honesty Jan 11 '16 at 22:52
  • 1
    Lots of things act differently with & without sudo, it's something to try if a system-type command like that doesn't work, as long as you know what it should do, and it doesn't have the potential to erase any important files or drives that is. – Xen2050 Jan 13 '16 at 18:15
2

It turns out I didn't have read access to the log file /private/var/log/system.log, so last didn't display anything. I just have to run sudo chmod 644 /private/var/log/system.log.

Thank you for your help, Xen2050!

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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