Sobes.tech
Junior — Middle

How can you obtain a list of recently logged-in users in Linux?

sobes.tech AI

Answer from AI

In Linux, to get a list of recently logged-in users, you can use the last command. It reads the /var/log/wtmp file and displays the login history.

Example usage:

last

The command will show a list of users, login times, session durations, and IP addresses (if the login was remote).

To view only the last few entries, you can use:

last -n 10

If you want to see not only successful logins but also login attempts, you can use lastb (requires root privileges), which reads /var/log/btmp.

How can you obtain a list of recently logged-in users… - sobes.tech