How do I display user last login date and time under Linux operating systems?
Linux use the following two files to keep track of user login sessions:
a] /var/run/utmp - List of current login sessions.
b] /var/log/wtmp - List of previous login sessions.
c] /var/log/btmp - List all the bad login attempt.
last command
The last command searches back through the file /var/log/wtmp file and displays a list of all users logged in (and out) since that file was created. Names of users and tty's can be given, in which case last will show only those entries matching the arguments. Names of ttys can be abbreviated, thus last 0 is the same as last tty0. Type the following command:
last
last username
Sample outputs:
vivek pts/3 :0.0 Thu Oct 29 00:46 still logged in vivek pts/0 :0.0 Wed Oct 28 23:14 still logged in vivek pts/2 :0.0 Wed Oct 28 22:12 - 23:11 (00:58) vivek pts/0 :0.0 Wed Oct 28 21:43 - 23:11 (01:27) vivek tty7 :0 Wed Oct 28 21:41 still logged in
Task: Find Out Who Was Logged In At A Particular Time
To display the state of logins as of the specified time to determine easily who was logged in at a particular time specify that time with -t option and look for "still logged in".
last -t YYYYMMDDHHMMSS
last -t 20091028231100 username
Task: Show Only Tty Matching Entries
Use the following syntax:
last tty
last tty2
last pts/3
lastb command
The lastb command is the same as last command, except that by default it shows a log of all the bad login attempts, enter:
lastb
lastb username
lastb vivek
lastb pts/2
How do I See All Failed Login Count and Other Information?
I recommend configuring PAM and use faillog command display all failed login attempts for given usernames.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop










![Linux Disable Bluetooth [ Bluetooth Input Devices (hidd) ]](http://s13.cyberciti.org/images/shared/rp/3/20.jpg)


{ 1 comment… read it below or add one }
thanks for the helpful information.
are there any conditions that we should be worried about under which a lastb command will return a “command not found” message in terminal?
i entered lastb and got that message.