FUNDAMENTALS A Complete Guide for Beginners
The users command in Linux is a useful tool to display the list of the users currently logged in to the system. In total this command prints one username per line on the terminal. Largely, the system administrator uses the users command to know who is currently logged in to the system.
A. Description
The user command in Linux is a utility tool to find the name of all users who are currently logged in to the system.
B. Syntax
The users command in Linux takes OPTION and FILE (as an argument). The syntax for the users command is given below.
users [OPTION]... [FILE]
C. Options
Not so many options are available to add to the syntax of the users command to modify its behavior. Here, I have listed the available options below. Nevertheless, If you want to know more about the users command, you can check the man (manual) page. To go to the man page, type the following command and press ENTER.
man users
Useful Options
- –help: It displays the help section of the users
- –version: It displays the version information of the users
Practical Examples of the “user” Command in Linux
The users command in Linux gives the list of users currently logged in to the system. Some practical examples of the users command are given below.
Example 1: Displaying the Username of the User Currently Logged in to the System
You can easily find the username of the user currently logged in to the system by using the users command in Linux. Here, I will display the name of the user currently logged in to the system on the terminal. To do so, follow the below procedures.
Steps to Follow >
➊ At first, open the Ubuntu Terminal.
➋ Then, copy the following command in the command prompt:
users
➌ Now, tap the ENTER button.
Output >
The following image shows that the users command in Linux has displayed the name of the user currently logged in to the system on the terminal.
Similar Readings
- The “usermod” Command in Linux [14+ Practical Examples]
- The “who” Command in Linux [6 Practical Examples]
Example 2: Displaying the Total Number of the Users Currently Logged in to the System
You can find the total number of users currently logged in to the system using the users command in Linux. Here, I will display the total number of users currently logged in to the system on the terminal. To do this task, follow the below procedures.
Steps to Follow >
➊ At first, open the Ubuntu Terminal.
➋ Then, type the following command in the command prompt.
users | wc -w
➌ Now, press the ENTER button.
Output >
The users command in Linux has displayed the total number of users currently logged in to the system on the terminal, as depicted in the below image.
Example 3: Displaying the Help Section of the “users” Command in Linux
You can easily display the help section of the user’s command on your terminal. Here, I will display the help section of the user’s command on the terminal. To achieve the same, follow the steps given below.
Steps to Follow >
➊ At first, open the Ubuntu Terminal.
➋ Then, type the following command in the command prompt.
users --help
➌ Now, press the ENTER button.
Output >
The following image shows that I have displayed the help section of the users command on the terminal.
Example 4: Displaying the Version of the “users” Command in Linux
You can display the version information of the user’s command currently running in your system. Here, I will display the version information of the user’s command currently running in my system. To do the task, follow the steps given below.
Steps to Follow >
➊ At first, open the Ubuntu Terminal.
➋ Then, copy the following command in the command prompt.
users --version
➌ Now, press the ENTER button.
Output >
The following image shows that I have displayed the version information of the users command on the terminal.
Conclusion
In this article, I have demonstrated the process of finding the names of the users currently logged in to the system using the users’ command in Linux. Therefore, I hope your productivity will increase with the help of these practical examples.
Similar Readings