Linux如何查询在线用户信息

1.关于我是谁?

1.1 whoami的用法:打印userid

root@snhzdriver:/# whoami
root

1.2 who am i的用法:打印目前登录的user信息

root@snhzdriver:/# who am i
root pts/1 2018-07-26 04:33 (a32201.etele.com)

2. w的用法:

2.1 w

  w查询登录的用户及其行为。
  第一行的信息依次表示为:现在的时间信息,系统运行时长,登录的用户数量,在过去1,5,15分钟的时间点上系统的平均负载。
  接下来是:登录名,tty名称,远程主机,登录时间,idle时间,JCPU,PCPU和目前运行的命令行。
root@snhzdriver:/# w
09:58:33 up 133 days, 20:32, 2 users, load average: 0.02, 0.03, 0.13
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/1 a32201.etel 04:33 2.00s 0.08s 0.08s -bash
root pts/4 hetc4000381.et Tue05 24:33m 0.23s 0.23s -bash

2.2 -h

  不打印抬头
root@snhzdriver:/# w -h
root pts/1 a32201.etel 04:33 4.00s 0.08s 0.08s -bash
root pts/4 hetc4000381.et Tue05 24:51m 0.23s 0.23s -bash

2.3 -u

  ignores the username while figuring out the currect process and cpu time
root@snhzdriver:/# w -u
10:16:45 up 133 days, 20:50, 2 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/1 a32201.etel 04:33 1.00s 0.09s 0.09s -bash
root pts/4 hetc4000381.et Tue05 24:51m 0.23s 0.23s -bash

2.4 -s

  使用短的模式,不输出登录时间,JCPU和PCPU时间。
root@snhzdriver:/# w -s
10:16:59 up 133 days, 20:50, 2 users, load average: 0.00, 0.01, 0.05
USER TTY FROM IDLE WHAT
root pts/1 a32201.etel 2.00s -bash
root pts/4 hetc4000381.et 24:51m -bash

2.4 -f

  Toggle printing the from(remote hostname)field.
root@snhzdriver:/# w -f
10:17:12 up 133 days, 20:51, 2 users, load average: 0.00, 0.01, 0.05
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root pts/1 04:33 0.00s 0.09s 0.09s -bash
root pts/4 Tue05 24:52m 0.23s 0.23s -bash

2.4 -i

  在from段,用IP信息代替主机名称
root@snhzdriver:/# w -i
10:17:28 up 133 days, 20:51, 2 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/1 172.18.100.129 04:33 2.00s 0.09s 0.09s -bash
root pts/4 172.18.100.118 Tue05 24:52m 0.23s 0.23s -bash

2.4 -V

  显示版本信息
root@snhzdriver:/# w -V
w from procps-ng 3.3.9

2.4 -o

  用老的格式输出
root@snhzdriver:/# w -o
10:18:04 up 133 days, 20:51, 2 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/1 a32201.etel 04:33 -bash
root pts/4 hetc4000381.et Tue05 24:52 -bash

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值