The “users” Command in Linux [4 Practical Examples]

LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now

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]

Note: Here, the OPTION and FILE enclosed by square brackets mean that OPTION and FILE are not mandatory for the command. Furthermore, three dots preceded by OPTION means that the users command can take multiple OPTIONs at a time.

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

Note: All options in Linux are case-sensitive. Therefore, you must be careful while using them.

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.The users command has displayed the name of the user currently logged in to the system on the terminal.


Similar Readings


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.The users command in has displayed the total number of users currently logged in to the system on the terminal.

Note: Here, I have passed the output of the user’s command to the wc command through piping.

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.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.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

Rate this post
Susmit Das Gupta

Hello everyone. I am Susmit Das Gupta, currently working as a Linux Content Developer Executive at SOFTEKO. I am a Mechanical Engineering graduate from Bangladesh University of Engineering and Technology. Besides my routine works, I find interest in going through new things, exploring new places, and capturing landscapes. Read Full Bio

Leave a Comment