Linux 之 w who lastlog 命令例子

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux 之 w who lastlog 命令例子相关的知识,希望对你有一定的参考价值。

w who lastlog 命令例子

w 查看当前登陆用户和当前操作

[[email protected] ~]# w
 22:52:39 up 133 days, 16:47,  8 users,  load average: 0.77, 0.31, 0.32
USER     TTY      FROM              [email protected]   IDLE   JCPU   PCPU WHAT
root     pts/0    remotepc.cedarhd 22:08   32:22   0.07s  0.04s vi applicationContext.xml
root     pts/2    10.3.244.3       22:47    0.00s  0.02s  0.00s w
root     tty1     :0               28Apr18 133days  1:17   1:17  /usr/bin/Xorg :0 -br -verbose -audit 4 -auth /var/run/gdm/au
root     pts/1    :0.0             28Apr18 16days  0.06s  0.06s /bin/bash
root     pts/5    remotepc.cedarhd 20:00    7:27   0.15s  0.15s -bash
root     pts/6    remotepc.cedarhd 21:01   60.00s  0.06s  0.06s -bash
root     pts/7    remotepc.cedarhd 21:30   44.00s  1:32   0.02s -bash
root     pts/8    remotepc.cedarhd 21:30    1:21m  0.10s  0.07s tail -500f catalina.out

who 查看当前登陆的用户

[[email protected] ~]# who
root     pts/0        2018-05-14 22:08 (remotepc.cedarhd.com)
root     pts/2        2018-05-14 22:47 (10.3.244.3)
root     tty1         2018-04-28 15:22 (:0)
root     pts/1        2018-04-28 15:22 (:0.0)
root     pts/5        2018-05-14 20:00 (remotepc.cedarhd.com)
root     pts/6        2018-05-14 21:01 (remotepc.cedarhd.com)
root     pts/7        2018-05-14 21:30 (remotepc.cedarhd.com)
root     pts/8        2018-05-14 21:30 (remotepc.cedarhd.com)

踢出pts/2用户的方法:

[[email protected] ~]# who
root     pts/0        2018-05-14 22:08 (remotepc.cedarhd.com)
root     pts/2        2018-05-14 22:47 (10.3.244.3)
root     tty1         2018-04-28 15:22 (:0)
root     pts/1        2018-04-28 15:22 (:0.0)
root     pts/5        2018-05-14 20:00 (remotepc.cedarhd.com)
root     pts/6        2018-05-14 21:01 (remotepc.cedarhd.com)
root     pts/7        2018-05-14 21:30 (remotepc.cedarhd.com)
root     pts/8        2018-05-14 21:30 (remotepc.cedarhd.com)
[[email protected] ~]# pkill -kill -t pts/2

lastlog 查看所有用户最后登陆时间

[[email protected] ~]# lastlog
Username         Port     From             Latest
root             pts/2    10.3.244.3       Mon May 14 22:47:03 +0800 2018
bin                                        **Never logged in**
daemon                                     **Never logged in**
adm                                        **Never logged in**
lp                                         **Never logged in**
sync                                       **Never logged in**
shutdown                                   **Never logged in**
halt                                       **Never logged in**
mail                                       **Never logged in**
uucp                                       **Never logged in**
operator                                   **Never logged in**
games                                      **Never logged in**

以上是关于Linux 之 w who lastlog 命令例子的主要内容,如果未能解决你的问题,请参考以下文章

linux-facl,whoami,who,w,last,lastlog,basename,mail,hostname,$random,case语句

Linux主机上用户的信息传递

linux 用户管理初级(下)

Linux日志文件utmpwtmplastlogmessages

linux 如何查看已经登录的用户

Linux之lastlog命令