1、w命令查看当前用户
[root@iZuf654dlv34jnzeptn4gmZ test]# w --help
Usage:
w [options]
Options:
-h, --no-header do not print header
-u, --no-current ignore current process username
-s, --short short format
-f, --from show remote hostname field
-o, --old-style old style output
-i, --ip-addr display IP address instead of hostname (if possible)
--help display this help and exit
-V, --version output version information and exit
[root@iZuf654dlv34jnzeptn4gmZ test]# w
10:35:02 up 134 days, 10:52, 2 users, load average: 0.01, 0.06, 0.06
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 056月17 134days 0.01s 0.01s -bash
root pts/0 116.226.109.51 10:30 6.00s 0.03s 0.00s w
命令信息含义上述显示的信息分别表示如下:
第一行显示系统的汇总信息,字段分别表示系统当前时间、系统运行时间、登陆系统用户总数及系统平均负载信息。对于如上图显示的字段意义为:
10:35:02表示执行w的时间是在上午10点35分02秒。
up 134 days, 10:52 表示系统运行134天10小时52分。
2 users 表示当前系统登陆用户总数为3。
Load average 与后面的数字一起表示系统在过去1,5,10分钟内的负载程度,数值越小,系统负载越轻。
从第二行开始构成一个登录用户信息列表,共有8个栏目,分别显示各个用户正在做的事情及该用户所占用的系统资源。
USER:显示登陆用户帐号名。用户重复登陆,该帐号也会重复出现。
TTY:用户登陆所用的终端。
FROM:显示用户在何处登陆系统。
LOGIN@:是LOGIN AT的意思,表示登陆进入系统的时间。
IDLE:用户空闲时间,从用户上一次任务结束后,开始记时。
JCPU:以终端代号来区分,表示在这段时间内,所有与该终端相关的进程任务所耗费的CPU时间。
PCPU:指WHAT域的任务执行后耗费的CPU时间。
WHAT:表示当前执行的任务。
2、who命令查看当前用户
[root@iZuf654dlv34jnzeptn4gmZ test]# man who
NAME
who - show who is logged on
SYNOPSIS
who [OPTION]... [ FILE | ARG1 ARG2 ]
DESCRIPTION
Print information about users who are currently logged in.
-a, --all
same as -b -d --login -p -r -t -T -u
-b, --boot
time of last system boot
-d, --dead
print dead processes
-H, --heading
print line of column headings
-l, --login
print system login processes
--lookup
attempt to canonicalize hostnames via DNS
-m only hostname and user associated with stdin
-p, --process
print active processes spawned by init
-q, --count
all login names and number of users logged on
-r, --runlevel
print current runlevel
-s, --short
print only name, line, and time (default)
-t, --time
print last system clock change
-T, -w, --mesg
add user's message status as +, - or ?
-u, --users
list users logged in
--message
same as -T
--writable
same as -T
--help display this help and exit
--version
[root@iZuf654dlv34jnzeptn4gmZ test]# who
root tty1 2017-06-05 23:42
root pts/0 2017-10-18 10:30 (116.226.109.51)
[root@iZuf654dlv34jnzeptn4gmZ test]# who -a
系统引导 2017-06-06 07:42
root + tty1 2017-06-05 23:42 旧的 482
运行级别 3 2017-06-05 23:42
root + pts/0 2017-10-18 10:30 . 4993 (116.226.109.51)
pts/1 2017-06-29 17:37 3961 id=ts/1 终端=0 退出=0
pts/2 2017-09-24 01:38 24836 id=ts/2 终端=0 退出=0
pts/3 2017-06-06 03:15 2276 id=ts/3 终端=0 退出=0
[root@iZuf654dlv34jnzeptn4gmZ test]# who -b
系统引导 2017-06-06 07:42
[root@iZuf654dlv34jnzeptn4gmZ test]# who -HT
名称 线路 时间 备注
root + tty1 2017-06-05 23:42
root + pts/0 2017-10-18 10:30 (116.226.109.51)
who -T
就可以得到该用户是否愿意接受其他用户信息(-T)还可以显示空闲时间(-I)及标题栏(-H)。
如果某个用户愿意接受信息,会在MESG栏中显示一个“+”,这时还可以使用命令MESG给用户发从信息。
3、whoami命令查看当前用户
[root@iZuf654dlv34jnzeptn4gmZ test]# whoami
root