获取当前登录用户相关信息:
[zhang@test ~]$ who
zhang pts/0 2012-09-24 08:58 (10.10.1.4)
zhang pts/1 2012-09-24 10:19 (10.10.1.4)
[zhang@test ~]$ w
10:22:18 up 83 days, 18:49, 2 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
zhang pts/0 10.10.1.4 08:58 2:56 0.01s 0.01s sshd: lhb [priv
zhang pts/1 10.10.1.4 10:19 0.00s 0.02s 0.00s w
[zhang@test ~]$
列出当前登录主机的用户的列表(如果同一个用户打开多个伪终端,那么会出现多个用户):
[zhang@test ~]$ users
zhang
[zhang@test ~]$
查看系统已经通电运行的多长时间:
[zhang@test ~]$ uptime
10:25:38 up 83 days, 18:52, 2 users, load average: 0.00, 0.00, 0.00
[zhang@test ~]$
要获取前一次启动和用户登录的回话信息:
[zhang@test temp]$ last
lhb pts/0 159.226.10.102 Mon Sep 24 10:28 still logged in
................部分信息省略
root xvc0 Thu Mar 3 19:25 - 19:25 (00:00)
reboot system boot 2.6.18-194.el5xe Thu Mar 3 19:23 (01:47)
wtmp begins Thu Mar 3 19:23:03 2011
获取单个用户的登录回话信息,可以使用:
[zhang@test temp]$ last zhang
zhang pts/0 10.10.1.4 Mon Sep 24 10:28 still logged in
zhang pts/0 10.10.1.4 Wed Jul 4 13:36 - 13:41 (00:04)
................部分信息省略
zhang pts/0 10.10.1.4 Tue Jul 3 12:57 - 16:47 (03:50)
zhang pts/0 10.10.1.4 Tue Jul 3 12:54 - 12:57 (00:02)
zhang pts/0 10.10.1.4 Tue Jul 3 10:07 - 11:56 (01:49)
wtmp begins Thu Mar 3 19:23:03 2011
[zhang@test temp]$
获取重启回话消息:
[zhang@test temp]$ last reboot
reboot system boot 2.6.18-194.el5xe Mon Jul 2 15:32 (83+19:00)
reboot system boot 2.6.18-194.el5xe Thu May 10 16:17 (136+18:15)
reboot system boot 2.6.18-194.el5xe Wed May 9 13:03 (1+03:13)
reboot system boot 2.6.18-194.el5xe Tue May 8 16:39 (00:09)
reboot system boot 2.6.18-194.el5xe Thu Apr 26 08:44 (00:02)
reboot system boot 2.6.18-194.el5xe Mon Apr 18 18:22 (00:02)
reboot system boot 2.6.18-194.el5xe Fri Apr 15 16:51 (3+00:53)
reboot system boot 2.6.18-194.el5xe Thu Apr 14 18:55 (00:02)
reboot system boot 2.6.18-194.el5xe Thu Apr 14 17:56 (00:24)
reboot system boot 2.6.18-194.el5xe Thu Apr 14 03:11 (00:20)
reboot system boot 2.6.18-194.el5xe Thu Apr 14 00:43 (02:27)
reboot system boot 2.6.18-194.el5xe Thu Mar 3 21:31 (00:03)
reboot system boot 2.6.18-194.el5xe Thu Mar 3 21:21 (00:07)
reboot system boot 2.6.18-194.el5xe Thu Mar 3 19:23 (01:47)
wtmp begins Thu Mar 3 19:23:03 2011
[zhang@test temp]$
获取失败用户登录回话信息:
[zhang@test temp]# lastb
zhang ssh:notty 10.10.1.4 Mon Sep 24 10:19 - 10:19 (00:00)
zhang ssh:notty 10.10.1.4 Thu Sep 20 09:05 - 09:05 (00:00)
zhang ssh:notty 10.10.1.2 Fri Sep 7 19:11 - 19:11 (00:00)
zhang ssh:notty 10.10.1.4 Thu Sep 6 16:15 - 16:15 (00:00)
zhang ssh:notty 10.10.1.4 Thu Sep 6 16:15 - 16:15 (00:00)
zhang ssh:notty 10.10.1.4 Thu Sep 6 16:15 - 16:15 (00:00)
zhang ssh:notty 10.10.1.4 Thu Sep 6 16:15 - 16:15 (00:00)
zhang ssh:notty 10.10.1.2 Mon Aug 20 17:29 - 17:29 (00:00)
zhang ssh:notty 10.10.1.4 Mon Jul 30 09:17 - 09:17 (00:00)
zhang ssh:notty 10.10.1.4 Mon Jul 30 09:17 - 09:17 (00:00)
zhang ssh:notty 10.10.1.4 Mon Jul 30 09:17 - 09:17 (00:00)
zhang ssh:notty 10.10.1.4 Wed Jul 4 13:41 - 13:41 (00:00)
root xvc0 Mon Jul 2 15:34 - 15:34 (00:00)
root xvc0 Thu May 10 16:18 - 16:18 (00:00)
root xvc0 Thu May 10 16:18 - 16:18 (00:00)
root xvc0 Thu Apr 14 00:44 - 00:44 (00:00)
root xvc0 Thu Apr 14 00:44 - 00:44 (00:00)
root xvc0 Thu Apr 14 00:44 - 00:44 (00:00)
root xvc0 Thu Apr 14 00:44 - 00:44 (00:00)
root xvc0 Thu Apr 14 00:44 - 00:44 (00:00)
root xvc0 Thu Apr 14 00:44 - 00:44 (00:00)
root xvc0 Thu Apr 14 00:43 - 00:43 (00:00)
btmp begins Thu Apr 14 00:43:59 2011
[zhang@test temp]#