Introduction to Linux Users
Sometimes when we are working on the Linux environment and we need the information about those users who are correctly login in the server. On the other hand, the user is a single entity to create single or multiple sessions with the Linux and work in shared resources via established sessions. In the Linux ecosystem, every user is aligned with an individual account and every individual account will contain the common directory structure (first time of user creation.)
The users’ command-line utility was written by Joseph Arceneaux and David MacKenzie.
Syntax of Users command
users [ OPTION ] ... [ FILE ]
- users: Using the user keyword in the command | syntax. It will take the argument as an option and file path. The end result will display the live login user information.
- OPTION: We can provide the different flags as options that are compatible with the user command.
- FILE: We need to pass two input files like /var/log/wtmp or /var/run/utmp.
How Linux Users Command Works and Roles?
The Linux users command is accepting two different sets of arguments i.e. the compatible OPTION and the input files. After providing the necessary inputs to the user’s command. The command will analyze it and provide the output in two different way
1. First Way: The user’s command is providing the list of users who are currently or live login on the server.
2. Second Way
- The Linux users command will provide both the past login and logout information of all the users. We just need to pass the input file to the user’s command in the shell environment.
- The major role of Linux users’ command is to provide accurate information of login user on the live environment.
Examples to Implement Linux Users Command
Below are examples to Implement Linux Users:
1. Users Command
The Linux users command will provide the live user logged in information on the server. There are no Sudo privileges that are needed to execute the command.
Explanation: As per the above command, we are using the simple mode of user command in the Linux CLI. Currently, we have login with the “EDUCBA” user and local server. As per the above command, we are getting the live login user those are login in the current server.
2. Users Command – Extract User from file
The user’s command is providing the login user information from the file as well. Below is the file path of these files.
The above files are not in a human-readable format. Both the files are encrypted and cannot read it.
Explanation: In the user’s command, there are different ways to identify the login user information. As per the above two users’ commands, we are passing the input files to the user’s command and get the information in two different formats.
- First format: In the Linux operating system, we are having the functionality to get all the login and logout user information. With the help of users command and input file “/var/log/wtmp”, we are able to get the past login and logout user information. Kindly refer to screenshot 1 (a).
- Second Format: In the Linux ecosystem, we are having the functionality to get the live login user information. With the help of users command and input file “/var/run/utmp”, we are able to get the live login user information. Kindly refer to screenshot 1 (b).
3. Users Command – Login User in Integer Value
The User command is providing the physical RAM memory and swap memory information in megabyte format. To get the memory information in a megabyte format. We need to use the “-m” option in the User command.
users /var/run/utmp | wc -w
Explanation: Let’s take a scenario, in the Linux server there are multiple users are login. There is very difficult to count the number of user at the same time. We need a utility or any functionality to give results in quick sec.
With the help of Linux users’ command, we can achieve it. As per the above user’s command, we are getting the login user value in an integer format.
4. Users Command – With Help
The user’s help command will provide a basic overview of the user’s command and exit it.
Explanation: People who are new in the Linux family. It is recommended to go with the “help” command first. The “help” command will provide the basic information on users’ command and how it will and all. Once the user will trigger the “help” command, it will display the information and exit.
5. Users command – with Version
The Linux users version command will provide the software or utility version details and exit it.
Explanation: The user’s version command will provide detailed information on users’ software or utility. The version information is more important while we are integrating different or third party software. It is recommended that we need to use the stable and latest version of the software or utility.
We have seen the uncut concept of “Linux Users Command” with the proper example, explanation, and command with different outputs. The user’s command is used to get the live user login information. It will also provide past login information as well. We can use this utility in a different way like audit report purpose, security module for application development, scripting, etc.
This is a guide to Linux Users. Here we discuss syntax, and user command, how does it work with examples to implement in detail. You can also go through our other related articles to learn more –