who — List users currently logged in — login name, tty, time across all 5 shells
Equivalents in every shell
whoReads `/var/run/utmp` (current sessions). Output columns: user, tty, login time, (optional) remote host. `who -a` adds idle time + boot time + run-level transitions. `w` is the richer cousin: same data plus load average + the command each user is currently running. `users` is the terse cousin: just space-separated usernames.
whoIdentical coreutils binary on Linux; macOS BSD `who` has slightly different flags (no `-a`, but `who -H` adds headers). On macOS, `who am i` (three words) is the historic way to ask "who is on THIS terminal" — returns one line for the current pty, useful inside a script that was invoked over SSH and needs to know the source IP (column 5).
whoSame external. For "what other sessions am I currently running", `who | grep $USER` (or fish-native `who | string match $USER`) shows every concurrent login as your account — useful for spotting "did I forget to log out of that server an hour ago?". On systemd hosts, `loginctl list-sessions --user $USER` gives a richer view including each session's service / class / leader PID.
quser`quser` (also accessible via `query user`) is the Windows Server / RDP-era binary that prints active sessions including console + RDP. Output columns: USERNAME, SESSIONNAME, ID, STATE (Active / Disc), IDLE TIME, LOGON TIME. Available on every modern Windows; Server SKUs include it always, client SKUs since Win10 1709. For object output instead of fixed-width text: `Get-CimInstance Win32_LogonSession` (much harder to interpret — `quser` is the right tool here).
query userSame underlying binary as pwsh `quser` — invokable as either `quser` or the older two-word form `query user`. Add a username to filter: `query user alice`. Add a remote server: `query user /server:DC01`. Returns exit code 1 if no sessions match — usable in batch scripts as a "is anyone logged in?" test.
Worked examples
List all current sessions
whowhowhoquserquery userShow only the current pty / session
who am iquser $env:USERNAMEquery user %USERNAME%Show login + idle + load (richer than `who`)
wwwGet-CimInstance Win32_LoggedOnUserquery sessionGotchas
- `who` reads `/var/run/utmp` (current) and `/var/log/wtmp` (history, via `last`). Both files are append-only logs that PAM writes on login. If your distro's init / login system bypasses PAM (some container init scripts, embedded systems), `who` shows nothing even though sessions are active — `loginctl list-sessions` (systemd) or `ps -eo pid,user,tty` (filter by tty) is the fallback.
- macOS `who am i` returns the user on the CURRENT terminal — but only if your terminal device is in utmp. Modern terminal emulators (iTerm2, Terminal.app, ghostty) record the pty; remote SSH sessions also do. But shells launched by `tmux new-session` from a daemonized tmux server may not be in utmp depending on tmux version — `who am i` then returns nothing. Use `id -un` for "my username on this terminal" if `who` is unreliable.
- Windows `quser` truncates usernames to 20 chars (legacy SAM limit) — long UPNs are shown as `alice.long-…`. For full names use `Get-CimInstance Win32_LogonSession | Get-CimAssociatedInstance -Association Win32_LoggedOnUser`. The truncation matters for scripts that compare `quser` output against `$env:USERNAME`: if your username is > 20 chars (rare, but UPN-style emails as username can hit it), the comparison silently fails.
- Both `who` and `quser` are POINT-IN-TIME — they describe sessions THAT EXIST RIGHT NOW. For "who logged in over the last 30 days" use `last -F` (Unix, reads wtmp) or `Get-EventLog Security -InstanceId 4624 | Where-Object {$_.TimeGenerated -gt (Get-Date).AddDays(-30)}` (Windows, reads Security event log 4624 = successful logon). Different data source, different retention behaviour.
- `quser` returns exit code 1 if the requested user has no active sessions ("No User exists for *"). Scripts that pipe `quser` into `Where-Object` will lose that signal — wrap with `$LASTEXITCODE` or use `Get-Process -IncludeUserName -Name explorer` as the more reliable "is this user actively using the desktop" check.