One of our regular reader asks:
I’d like to discover information about who is currently using the system. When a user logs in what files are updated in UNIX / Linux?
Linux / UNIX have utmp and wtmp files to keep login records. Following three files keeps track of all logins and logouts to the system.
=> /var/run/utmp : List of current login sessions.
=> /var/log/wtmp : Database of past user logins / previous login sessions.
=> /var/log/lastlog : Last logins information about users
How do I access login records files?
These are a binary log files, and grows linearly at its end. So you cannot view records using cat or other text based utilities. The file <utmp.h> declares the structures used to record information about current users in the file. This can be accessed using C programs or other specialized utilities:
- The utmp file is used and accessed by the following commands:
- The wtmp file is used and accessed by the following command:
Suggested readings:
- Man pages - ac(1), date(1), last(1), login(1), who(1), getutent(3), updwtmp(3), init(8), wtmp(5)
- Header file /usr/include/utmp.h
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




![7 Powerful Firefox Password Managers [ Add-ons ]](http://s13.cyberciti.org/images/shared/rp/3/26.jpg)








{ 4 comments… read them below or add one }
lsof will give you a list of all files being accessed at the moment and the users that are accessing them, among other things.
there is apparently another file which not many know of is /var/log/btmp and the related command to read it is lastb.
lastb is same as that of last except that it shows all the bad login attempts which are recorded into /var/log/btmp, if the file is not present you would have to touch it to get started.
Nikhil
Nikhil,
Oh I just forgot about lastb., I appreciate your post.
Can you pls tell me how to information on this log files