linux查看用户登录信息2-who命令

时间:2022-12-06 05:16:45

who命令与w命令相似,但要比w命令显示更加详细的信息。
[root@rusky opt]# man who
WHO(1) User Commands WHO(1)

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
output version information and exit
============
常用who命令:

[root@rusky opt]# who
root pts/ Dec : (192.168.1.111)
rusky1 pts/ Dec : (192.168.1.111)
rusky1 pts/ Dec : (192.168.1.111) [root@rusky opt]# who -b --time of last system boot
system boot Dec : [root@rusky opt]# who -r ---print current runlevel
run-level Dec : [root@rusky opt]# who -q ---all login names and number of users logged on
root rusky1 rusky1
# users= [root@rusky opt]# who -s
root pts/ Dec : (192.168.1.111)
rusky1 pts/ Dec : (192.168.1.111)
rusky1 pts/ Dec : (192.168.1.111) [root@rusky opt]# who -a
system boot Dec :
run-level Dec :
LOGIN tty3 Dec : id=
LOGIN tty2 Dec : id=
LOGIN tty4 Dec : id=
LOGIN tty5 Dec : id=
LOGIN tty6 Dec : id=
root + pts/ Dec : . (192.168.1.111)
rusky1 + pts/ Dec : : (192.168.1.111)
rusky1 + pts/ Dec : : (192.168.1.111)
pts/ Dec : id=ts/ term= exit=