当前位置: 首页 > Linux

Linux查看最近登录成功-失败的用户信息

时间:2023-04-06 02:08:08 Linux

几种常用的Linux查看最近登录成功/失败的用户信息空闲时间等[root@server06~]#lastchenpts/1ip-10-0-7-27.ap-5月19日星期二16:45仍然登录incasepts/2ip-10-0-7-27.ap-5月19日星期二10:22-10:24(00:01)[root@server06~]#w-i18:05:01up1day,11:04,5users,loadaverage:0.00,0.00,0.00USERTTYFROMLOGIN@IDLEJCPUPCPUWHATrootpts/010.0.7.2716:475.00s0.07s0.00sw-i1.Linuxusers查看在线用户[root@server06~]#userscaserootchen2.Linuxwho查看在线用户并显示终端、时间、登录地址等信息,显示系统中有哪些用户在上面.显示的信息包括用户ID、使用的终端、从哪里连接、在线时间、死机时间、CPU使用率、Actions等。参数说明:-H或--heading:显示各栏的标题信息栏;-u显示空闲时间,如果用户在前一分钟内执行过任何操作,将被标记为“.”,如果用户超过24小时没有做任何事情,则标记“旧”字符串-q或--count:只显示账户名和登录系统的总人数;[root@server06~]#whorootpts/02020-05-1909:07(ip-10-0-7-27.compute.internal)casepts/12020-05-1909:15(ip-10-0-7-27.compute.internal)chenpts/22020-05-1910:22(ip-10-0-7-27.compute.internal)显示标题栏,只显示当前用户IDLE。这意味着用户当前处于活动状态[root@server06~]#who-HuNAMELINETIMEIDLEPIDCOMMENTrootpts/02020-05-2016:47。4958(ip-10-0-7-27.compute.internal)casepts/12020-05-2016:53。5084(ip-10-0-7-27.compute.internal)chenpts/22020-05-2016:4900:185003(ip-10-0-7-27.compute.internal)rootpts/32020-05-2016:5000:225032(ip-10-0-7-27.compute.internal)centospts/42020-05-2016:5400:185109(ip-10-0-7-27.compute.internal)显示登录系统的账户名和总人数[root@server06~]#who-qrootyqserviceyqservicerootcentos#users=53.linuxlast命令用于显示用户的最新登录信息-R省略hostname字段-numdisplay前numusernames显示用户名的登录信息。最后2个登录成功的用户记录用户、终端、时间、在线时长**stilllogined表示当前在线[root@server06~]#last-2chenpts/1ip-10-0-7-27.ap-5月19日星期二16:45仍然登录incasepts/2ip-10-0-7-27.ap-TueMay1910:22-10:24(00:01)显示完整主机名有时太长,默认显示不完整[root@server06~]#last-a-2centospts/45月20日星期三16:54仍然登录ip-10-0-7-27.ap-south-1.compute.internalyqservicpts/15月20日星期三16:53仍然登录ip-10-0-7-27。ap-south-1.Compute.internal省略主机名字段[root@server06~]#last-R-2chenpts/1TueMay1916:45stillloggedincasepts/2TueMay1910:22-10:24(00:01)显示centos登录信息[root@server06~]#lastcentos-5centospts/4ip-10-0-7-27.ap-WedMay2016:54stillloggedincentospts/4ip-10-0-6-211.ap5月8日星期五12:34-13:20(00:45)centospts/1ip-10-0-6-211.ap5月6日星期三11:46-13:20(2+01:33)centospts/1ip-10-0-7-27.ap-5月6日星期三11:12-11:13(00:01)centospts/1ip-10-0-7-27.ap-WedMay609:39-09:41(00:01)**4..Linuxlastb命令用于列出登录系统失败用户的相关信息,并显示完整的主机名最近2条登录失败的用户记录[root@server06~]#lastb-acentosssh:nottyThuMay715:43-15:43(00:00)ip-10-0-7-27.ap-south-1.compute.internal5.Linuxw命令用于显示当前登录的用户信息system-f打开或关闭显示用户从哪里登录系统。-h 不显示各栏的标题信息栏。-i 显示实例IP地址-s 使用简洁的格式列表,不显示用户登录时间、终端会话作业和程序消耗的CPU时间。显示当前用户,不显示登录位置用户终端登录主机名登录时间限制时间tty进程CPU占用率当前进程CPU占用率runcommand[root@server06~]#w18:02:14up1day,11:02,5个用户,平均负载:0.00,0.00,0.00USERTTYFROMLOGIN@IDLEJCPUPCPUWHATrootpts/0ip-10-0-7-27.ap-16:471.00s0.07s0.00swrootpts/1ip-10-0-7-27.ap-16:5349:570.00s0.00s-bashcasepts/2ip-10-0-5-16.ap-16:491:08m0.00s0.00spingwww.baidu.comrootpts/3ip-10-0-5-16.ap-16:501:11m0.00s0.00s-bashcentospts/4ip-10-0-7-27.ap-16:541:08m0.00s0.00s-bash显示IP地址[root@server06~]#w-i18:05:01up1day,11:04,5users,loadaverage:0.00,0.00,0.00USERTTYFROMLOGIN@IDLEJCPUPCPUWHATrootpts/010.0.7.2716:475.00s0.07s0.00sw-irootpts/110.0.7.2716:5352:440.00s0.00s-bashcasepts/210.0.5.1616:491:10m0.00s0.00spingwww.baidu.comrootpts/310.0.7.2716:501:14m0.00s0.00s-bash