Let’s cut to the chase: if you spend any time working in a Linux or Unix terminal, there’s one command that’s been hiding in plain sight this whole time—and it’s almost certainly saved you from retyping a 10-character SSH hostname or hunting for a command you ran 12 hours ago. That command is last, and as someone who’s built and sold enterprise-grade terminals for the last 8 years, I can tell you it’s one of the most underrated tools in any sysadmin’s or dev’s toolbox. Before we dive into how to use it, let’s get one thing straight: I’m not here to pitch overpriced “magic terminal” software. My company builds reliable, open-source-friendly terminals for teams that need rock-solid access to system logs and user activity—no bloat, no hidden fees. That’s why last is such a perfect fit for our users; it works seamlessly with the core Unix system we build our terminals on. Terminal

First: What Is the last Command, Exactly?
If you’ve ever tried to figure out who logged into a server last night before a critical deployment went sideways, or wondered why a process you didn’t start is running on your test machine, last is your answer. It parses the /var/log/wtmp file, which is a binary log that records every user login, logout, system reboot, and even runlevel change on your Unix or Linux system. Unlike text logs, wtmp is designed to capture timestamps, usernames, and session details in a structured format—so last doesn’t just dump random lines; it outputs organized, human-readable (and machine-readable, for scripts) data about every session that’s occurred since the log was created.
I see teams miss this all the time: when they’re debugging an issue, they’ll fumble through 10 different log files when last can give them a full timeline in 3 seconds. For context, last year a DevOps team that’s a client of ours reached out in a panic because their staging server had been accessed by someone outside their team at 2 a.m. Using last, they traced the session back to a new intern who’d forgotten to log out of a shared terminal instance on the team’s jump host. No need to pull forensics for 2 hours—just one last call, and the problem was solved. That’s the power of this command.
The Basics: Running last and Reading the Output
Let’s start with the simplest use case: open your terminal (the one you’re using right now, if it’s a Unix-based system) and type last then hit Enter. What you’ll get is a list of every user who’s logged in, sorted by the most recent session first. Each line has 5 core pieces of information:
- The username of the person who logged in.
- The terminal (or “tty”) they used. TTY stands for teletype, and it tells you how the user accessed the system—
tty1totty6are physical console terminals,pts/0,pts/1are pseudo-terminals (like SSH sessions or terminal windows in a GUI), and even entries likesystem bootfor reboots. - The remote host or IP address the user logged in from. If it’s a local login (like sitting right at the server’s keyboard), this field is blank. For SSH logins, you’ll see the public IP of the user’s computer or the hostname of a jump server.
- The start and end time of the session. If the session is still active, you’ll see
still logged inat the end of the line. If it ended, you’ll see the total duration—like02:15for 2 hours and 15 minutes.
Wait a second—let’s test this right now. If I run last on my work test server, the first line might look like this: jdoe pts/0 192.168.1.45 Mon Oct 16 09:23 still logged in. That makes perfect sense: Jane Doe is connected via an SSH session from her home IP, logged in at 9:23 a.m. on Monday, and still in there. The line before that would be the previous session, maybe smith pts/2 desktop-laptop Sun Oct 15 14:10 - 17:45 (03:35)—Bob Smith used his desktop hostname, was logged in for 3 hours and 35 minutes, and logged out on Sunday.
Customizing last for Specific Use Cases
The real magic of last comes with its handful of simple, powerful flags that let you filter the output so you don’t have to scroll through 100 lines of old sessions to find what you need. Let’s go over the ones I use every day, with real examples from how our clients use them in their enterprise terminals.
First, if you only want to see the last N sessions, use the -n flag. For example, last -n 5 will show you the 5 most recent logins. This is perfect if you’re checking who’s currently on the system, or just need a quick snapshot of recent activity without cluttering your terminal. One of our enterprise clients uses this flag in a custom terminal dashboard for their DevOps team—they have it set to show the last 10 logins at a glance, so someone can spot an unauthorized login before they even pull up the full log.
Next, to filter by a specific user, add the username at the end of the command. If you want to see only Jane’s sessions, run last jdoe. This is way faster than piping the output through grep every time, though you can combine flags too. For example, last -n 10 root will show the last 10 times the root user logged in—critical for security audits, since root access is the highest privilege on a system.
Here’s a flag that trips a lot of new users up: -F, which stands for “full timestamps.” By default, last shows times relative to the current day (like “Mon 09:23”) but -F will show the full date and year, so you can see a session that happened 3 months ago without having to calculate. This is invaluable for compliance teams that need to track access for audit reports. I had a healthcare client last year that required a full log of all staff access to patient data for each quarter—they used last -F to pull that data in 10 seconds per server, instead of manually searching through text logs for hours.
Want to see system reboots and shutdowns? last -x is your friend. The -x flag adds “runlevel” and “system boot/shutdown” entries to the output, so you can see exactly when the server was restarted or powered off. For example, last -x will show a line like reboot system boot 5.15.0-78-generic Mon Oct 16 08:00 still running which means the server booted up at 8 a.m. on Monday, and is still running. Our network operations team uses this flag to track server uptime across their entire fleet, right from their terminal dashboard.
One more flag that’s perfect for troubleshooting: -a, which moves the remote host/IP address to the end of the line. This makes the output much easier to read, especially if you’re logging multiple sessions. Compare:
jdoe pts/0 192.168.1.45 Mon Oct 16 09:23 still logged in
vs. the same line with -a:
jdoe pts/0 Mon Oct 16 09:23 still logged in 192.168.1.45
It’s a small change, but it makes a huge difference when you’re scanning through dozens of lines to spot a specific IP address.
Common Pitfalls and How to Avoid Them
Before you start using last for everything, let’s talk about a few mistakes I see people make all the time. First: wtmp logs rotate, just like any other system log. On most systems, /var/log/wtmp gets rotated weekly or monthly by logrotate, so if you’re looking for a session that happened 6 months ago, it might not be in the current wtmp file. In that case, you can look at the rotated logs, like /var/log/wtmp.1, by running last -f /var/log/wtmp.1—the -f flag lets you specify a different log file. That’s a lifesaver if you need to audit old activity.
Second: last won’t show every single user action. It only tracks full login and logout sessions. That means if a user is already logged in and their session drops (like a network hiccup), last won’t register that until the system marks the session as inactive. For interactive work, that’s fine, but if you’re debugging background processes, you’ll want to combine last with other commands like who or lastb (which shows failed login attempts, by the way—super important for security).
Third: Permissions matter. To see the full last output for all users, you need read access to /var/log/wtmp. On most systems, regular users can run last, but if you’re getting a “permission denied” error, you’ll need to use sudo to run it as root. That’s a security feature, not a bug—you don’t want just anyone seeing all the login activity on your server.
How We Build Terminals That Work Better With last
At our company, every terminal we build is optimized for tools like last because we know how critical these simple, powerful commands are for system admins and devs. A lot of commercial terminals overcomplicate things with fancy GUIs and paid features, but our core offering is built on open Unix systems, so last works exactly as it’s supposed to—no hacks, no workarounds. We also add small, practical integrations: our terminal lets you save common last commands as custom shortcuts, so you can pull up a full audit log with one click, or view only active sessions without typing the whole flag sequence.
Last quarter, we worked with a mid-sized SaaS company that was struggling with how to manage access to their development servers. Their old terminal software didn’t integrate with system logs, so their DevOps team spent 30 minutes every morning checking each server for unauthorized logins. After switching to our terminal, they set up a custom dashboard that runs last -n 10 -x on all 12 of their dev servers and displays the output in a single, scrollable view. Now they check that dashboard in 30 seconds, and have caught 2 unauthorized login attempts that would have slipped through before. That’s the kind of real value we deliver—tools that make you more efficient, not more stressed.
Final Thoughts: Stop Ignoring the Simple Tools
I started this by saying last is underrated, and that’s because it’s true. In a world where everyone’s talking about AI tools that can debug your code or manage your servers for you, it’s easy to forget that the simplest, most reliable commands have been around for 40 years—and they still do the job better than any new tool. The last command doesn’t need a subscription, doesn’t need an internet connection, and doesn’t require a 10-step onboarding process. It just works, right in your terminal, when you need it most.

If you’re a system admin, DevOps engineer, or even just a power user who works with Unix systems, take 5 minutes today to play with last—pull up a log of your own sessions, check when your server was last rebooted, or filter for a specific user’s activity. You’ll be surprised how much time it saves you in the long run.
Switch Terminals If your team is looking for a terminal that works seamlessly with tools like last (and doesn’t nickel-and-dime you for basic features), we’d love to chat. We build terminals for teams that value reliability and simplicity, and we can help you set up custom workflows that fit your specific needs. Don’t let another day of fumbling through messy logs slow you down—reach out to us today to discuss your requirements.
References
- Unix Manual Page for
last - Linux
wtmpandbtmpLog File Documentation - System Log Rotation and
logrotateBest Practices - Unix Terminal Session Management Standards
Hangzhou Lingcheng Technology Co., Ltd.
Address: Room 1613, 16th Floor, Building 3, No. 99 Wangzhou Road, Liangzhu Street, Yuhang District, Hangzhou City, Zhejiang Province
E-mail: LCKJ0408@163.com
WebSite: https://www.lingchengelectric.com/