Linux View User Login record

Source: Internet
Author: User

Information about user logins is recorded in files such as utmp (/VAR/RUN/UTMP), wtmp (/var/log/wtmp), btmp (/var/log/btmp), and Lastlog (/var/log/lastlog).

The WHO, W, and users commands use the utmp (/var/run/utmp) file to query the current logged-on user's information.
The last and AC commands use the wtmp (/var/log/wtmp) file to query the information of the user who is currently logged in to the system.
The LASTB command queries the btmp (/var/log/btmp) file for information about all users who have failed to log on to the system.
The Lastlog command queries the user for the last logon information through the Lastlog (/var/log/lastlog) file.

Who command: Displays information about the user who is currently logged on

who Huey     pts/1        2015-05-11 18:29 (192.168.1.105) sugar    pts/2        2015-05-11 18:29 (192.168.1.105 )

W command: Displays the logged on user and the currently executing task

W 18:30:51 up 3 min,  2 users,  load average:0.10, 0.14, 0.06USER     TTY      from              [email protected]   IDLE   Jcpu   PCPU whathuey     pts/1    192.168.1.105    18:29    3.00s  0.52s  0.00s wsugar    pts/ 2    192.168.1.105    18:29    1:07   0.47s  0.47s-bash

The users command: Displays the user name of the user who is currently logged on

UsersHuey Sugar

Last command: Displays information about the user who is currently logged on to the system

last root     pts/3        192.168.1.105    Mon may 18:33-18:33  (00:00)    sugar    pts/2        192.168.1.105    Mon May one 18:32   still logged in   sugar    pts/2        192.168.1.105    Mon May 11 18:29- 18:32  (00:02)    Huey     pts/1        192.168.1.105    Mon may one 18:29 still   logged in   reboot   system boot  3.5.0-43-generic Mon may 18:27-18:33  (00:05)    Huey     PTS/1        192.168.1.105    Sat may  9 10:57-17:31  (06:33)

LASTB command: Displays information for all users who have failed to log on to the system

sudo lastbbtmp begins Sat may  9 09:48:59 2015

Lastlog command: Displays information about the last time a user logged in

lastlog User name           port     from             last login time root             pts/3    192.168.1.105  May 11 18:36:43 +0800 2015daemon * * Never logged in **bin * * never logged in **sys * * never logged in **......hplip * * never logged in                                      **saned                                      * * never logged in **huey             pts/1    192.168.1.105  May 18:29:40 +0800 2015guest-miznkv                               * * never logged in **guest-bcf1si                               * * Never logged in **sugar            pts/2    192.168.1.105  May 18:32:28 +0800 2015mysql                                      * * never logged in **sshd                                       * * Never logged in * *

AC command: Displays statistics of user connection time
A) Displays the total connection time for each day

ac-d May  9total        6.55Todaytotal        0.54

b) Show the total connection time for each user

ac-pHuey                                 6.78sugar                                0.23root                                 0.12total        7.13

Linux View User Login record

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.