Linux, who command Detailed

What is the who command
who command displays information about all users currently logged on the local system. Shows the following: login name, tty, login date and time. Enter the whoami displays your login name, tty, date and time you log on. If the user is logged in from a remote machine, the host name of the machine will be displayed.
who command can also display line activity occurred since the elapsed time, process the command interpreter (shell) logo, logon, logoff, reboot and change the system clock, but also display other processes generated by the initialization process.
Access: All users can use the
Note: It does not show those who log in through the su command to switch users

grammar

who   -  [abdHlst..]   [user]

Common command parameters

-a   等同于指定 -bdprtTu
-b   系统最近启动时间和日期
-d   打印一个僵死的进程(显示没有被 init 重新生成的所有到期的进程)
-h   打印一个标题
-l   列出登录进程
-p   列出活动进程
-r   显示当前的运行级别
-s   仅列出名字、线路和时间字段。这个标志是缺省值;因此,who 和 who -s 命令是等效的。
-t   显示 root 用户上一次用 date 命令对系统时钟做的更改。如果 date 命令自从系统安装以来还没有被运行过, who -t 命令就不产生输出。

Examples
show the user currently logged on the system

[root@centos7 data]# who
root     pts/0        2019-08-16 22:08 (192.168.34.1)
root     :0           2019-08-16 22:34 (:0)
root     pts/1        2019-08-16 22:34 (:0)
root     pts/2        2019-08-17 09:53 (192.168.34.1)

Show title bar

[root@centos7 data]# who -H
NAME     LINE         TIME             COMMENT
root     pts/0        2019-08-16 22:08 (192.168.34.1)
root     :0           2019-08-16 22:34 (:0)
root     pts/1        2019-08-16 22:34 (:0)
root     pts/2        2019-08-17 09:53 (192.168.34.1)

Display terminal attribute

[root@centos7 data]# who -T -H
NAME       LINE         TIME             COMMENT
root     + pts/0        2019-08-16 22:08 (192.168.34.1)
root     ? :0           2019-08-16 22:34 (:0)
root     + pts/1        2019-08-16 22:34 (:0)
root     + pts/2        2019-08-17 09:53 (192.168.34.1)

Show only the current user

[root@centos7 data]# who -m -H
NAME     LINE         TIME             COMMENT
root     pts/0        2019-08-16 22:08 (192.168.34.1)

Simple Information Display

[root@centos7 data]# who -q
root root root root
# users=4

Added: Displays the current logged-on user

[root@centos7 data]# whoami
root

Guess you like

Origin blog.51cto.com/11620628/2430305