← 返回命令列表

Linux command

who 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Show who is logged in

who

Show current user

who am i

Show with column headers

who -H

Show login time and idle time

who -u

Show all available information

who -a

Count logged in users

who -q

Show system boot time

who -b

说明

who displays information about users currently logged into the system. It reads from /var/run/utmp (or another specified file) which tracks login sessions. The basic output shows username, terminal line, and login time. Additional options reveal idle time, process IDs, and message status (whether the user accepts write/talk messages). who am i shows information about the original login session. Unlike whoami (which shows the effective user), who am i displays the user who originally logged in, even after su to another account. The command can read historical login data from /var/log/wtmp to show past logins.

参数

-a, --all
Print all available information
-b, --boot
Time of last system boot
-d, --dead
Print dead processes
-H, --heading
Print column headers
-l, --login
Print system login processes
-q, --count
Only usernames and count of logged-in users
-r, --runlevel
Print current runlevel
-p, --process
Print active processes spawned by init
-s, --short
Print only name, line, and time (default)
-t, --time
Print last system clock change
-T, -w, --mesg
Add user's message status (+, -, ?)
-u, --users
List users logged in
--lookup
Attempt to canonicalize hostnames via DNS
am i
Print only current terminal's user info

FAQ

What is the who command used for?

who displays information about users currently logged into the system. It reads from /var/run/utmp (or another specified file) which tracks login sessions. The basic output shows username, terminal line, and login time. Additional options reveal idle time, process IDs, and message status (whether the user accepts write/talk messages). who am i shows information about the original login session. Unlike whoami (which shows the effective user), who am i displays the user who originally logged in, even after su to another account. The command can read historical login data from /var/log/wtmp to show past logins.

How do I run a basic who example?

Run `who` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a, --all do in who?

Print all available information