users – Prints the names of all logged-in users on the current host

The users command in Linux is used to display the list of all logged-in users on the current host. This command is useful for system administrators to check the number of users currently logged in and their usernames.

Overview

The syntax for the users command is as follows:

users [OPTION]... [FILE]

The users command without any options or arguments displays the list of usernames of all logged-in users on the current host, separated by spaces.

For example:

$ users
johndoe janedoe

The users command can also take a file as an argument and display the list of users who are logged in on the specified terminal or pseudo-terminal.

For example:

$ users /dev/pts/0
johndoe janedoe

Options

The following table lists the available options for the users command:

Option Description
-q, –count Displays the number of logged-in users instead of their usernames.
-s, –seconds Displays the date and time when each user logged in.
-u, –help Displays the help message and exits.
–version Displays the version information and exits.

Troubleshooting tips

If the users command is not displaying any output, it may be because there are no users logged in on the current host. Alternatively, it could be due to incorrect usage of the command or a system issue.

If the users command is displaying an error message, it is recommended to check the syntax and usage of the command. It may also be helpful to consult the command’s manual page by running man users.

Notes

  • The users command only displays the usernames of logged-in users and does not provide any additional information such as their IP address or location.
  • The users command may not display the complete list of logged-in users if the system is configured to hide certain users or if the user has set their account to be hidden from other users.