Read the Manual: last

A tiny tool I used for the first time in late September, 2024.

People interested in learning how the command lines tools on their computer work.

A few weeks ago, I was curious what my laptop’s uptime” was — in part because it was acting a bit funky — and I realized I had no idea how to answer that question, but I also figured (correctly) it should be simple, so I looked it up. This Thursday’s Read the Manual adventure is about the answer: last.

last tells you when users last logged in. (And ttys, which is great for administrating systems which have people accessing them other ways. But for my purposes: users.) Fair warning: if you just type last you may get a lot of data. A year’s worth, in my case: 2885 lines. To limit that output, you can pass -n to get how many of the most recent logins to show

More usefully, though, since login happens on a modern Mac every time you unlock the computer (which is a lot, if you’re like me!), you can ask for just reboots with last reboot. last shutdown works, too. These are a fun hack” on the basic design: last <username> gives you the last login for a given user — so shutdown and reboot are just pseudo users”. Don’t name your user one of those, I guess. (Good advice for lots of reasons!)

Also, both the man page and tldr say a lot of things which appear to be blatantly false on macOS, which is weird. The files the man page references? They don’t exist! My guess is the tldr difference is a BSD-vs.-Linux-ism, but I have no idea why the man page is wrong!

That’s it for this one — short and sweet but really useful!