Front | Info | Lists | Newsfeeds | Study Guide | What is BSD? |
|
This is the BSDA Study Guide Book written via a wiki collaboration. This is a work in progress. You may contribute to or discuss this specific page at http://bsdwiki.reedmedia.net/wiki/Determine_who_is_currently_on_the_system_or_the_last_time_a_user_was_on_the_system.html. Determine who is currently on the system or the last time a user was on the systemConceptBSD systems maintain databases which can be queried for details regarding logins. Be familiar with the database names and the utilities available for determining login information. IntroductionAfter logging into an account on BSD system we can see an information like:
This and other kind of information about users and their doings (logins and logouts) is stored in three files:
Of course, manually gathering information from aforementioned files makes no sense at all. Thus the BSD systems are equiped with a handful of simple commands that will fetch required information for us. ExamplesDetermining user's last login time and date can be performed with a lastlogin(8) command:
When executed with no user names lastlogin(8) displays information for all users. Adding user name makes lastlogin(8) display information regarding only specified user. The last(1) command displays a list of last logins. Executed without any parameters returns a list for user executing it. To minimize the scope of returned list we can use the -n flag, specifying maximum number of lines.
The users(1) utility lists the login names of the users currently logged into the system.
The w(1) and who(1) tools returns a little more detailed information on current users. The who(1) command displays who is on the system, while the w(1) presents also an information on what they are doing as well as some other system information (covered in section Determine the last system boot time and the workload on the system).
BSD systems give us also an ability to check some more information on system users. To do so, we can use a finger(1) utility with optional user name.
Practice Exercises
More informationwtmp(5), utmp(5), w(1), who(1), users(1), last(1), lastlogin(8), lastlog(5), finger(1)
|