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 [FILE]

PARAMETERS

FILE
    Use the specified file instead of /var/run/utmp. Common alternative files are /var/log/wtmp or /var/log/utmp

DESCRIPTION

The users command in Linux displays the usernames of users currently logged into the system. It prints the usernames on a single line, separated by spaces. If the same user is logged in multiple times, their username will appear multiple times. It is a very basic command, intended for quick identification of active users.

It's important to note that users does not provide detailed information like login times or terminal information. For more comprehensive user activity monitoring, commands like w, who, and last are more suitable. users provides a simple, space-separated list, making it easy to parse in scripts if needed. The output reflects the users listed in the utmp file, which tracks active login sessions.

CAVEATS

The information presented by users is derived from the utmp file, so its accuracy depends on the proper maintenance of that file by the system. If utmp is corrupted or incomplete, the output might be inaccurate. Also, the command gives very limited information about the users and their activities.

FILE DEPENDENCIES

The users command relies on the /var/run/utmp file (or a file specified as a command argument) to retrieve the current user login information. If this file is missing or has incorrect permissions, users might not function correctly or display accurate data.

HISTORY

The users command has been a part of Unix-like operating systems for a long time, dating back to the early days of Unix. Its primary function has remained consistent: to quickly display a list of logged-in users. It's a fundamental utility for basic system administration and monitoring.

SEE ALSO

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

Copied to clipboard