LinuxCommandLibrary

users

Display users currently logged into the system

TLDR

Print logged in usernames

$ users
copy

Print logged in usernames according to a given file
$ users [/var/log/wmtp]
copy

SYNOPSIS

users [OPTION]...

PARAMETERS

--help
    Display a help message and exit.

--version
    Output version information and exit.

DESCRIPTION

The users command is a straightforward utility designed to display the usernames of all users currently logged into the system. It retrieves this information by parsing the system's `utmp` file, which maintains a record of login and logout activities. Unlike more verbose commands such as who or w, users focuses solely on presenting a clean list of usernames.

The output typically shows all active usernames, separated by spaces, on a single line. This simplicity makes it particularly useful for quick checks, scripting, or automated tasks where only the identity of the active users is required, without needing additional details like login time, terminal, or idle status. It provides a concise snapshot of who is actively utilizing the system at the moment the command is executed.

CAVEATS

The users command relies on the integrity and currency of the system's utmp file (commonly found at `/var/run/utmp` or `/var/log/utmp`). If this file becomes corrupted or is not properly updated due to system issues or specific session types (e.g., abnormal termination of an SSH session), the output of users might not be entirely accurate. It provides only a list of usernames and no further details such as login time, terminal, or idle status. For more comprehensive user information, other commands like who or w should be used.

HISTORY

The users command is a fundamental and long-standing utility in Unix-like operating systems, serving its primary purpose of listing logged-in users consistently for decades. It's often found as part of the traditional `login` or `who` utilities package. In contemporary Linux distributions, users is typically included as part of the GNU `coreutils` package, which ensures its widespread availability and largely uniform behavior across different systems. Its minimalist design reflects the early Unix philosophy of creating small, focused tools that perform one task well, making them easily combinable for more complex operations.

SEE ALSO

who(1), w(1), last(1), logname(1), finger(1)

Copied to clipboard