How To Get Account Information & Login Details on Linux
Different forms and commands to know how to get account information and login details on Linux.
When managing and managing Linux operating systems, it is ideal to know different ways to obtain information about tasks that are carried out daily there.
One of the most frequent tasks that we can execute or that is ideal to know support tasks is everything related to users who log in to the system.
Today we will give some ways how we can obtain this information in Linux.
Get User Info using ID Command
ID is a simple command line utility that allows us to display a user ID with its real and active groups, for this we will use the following syntax:
id user
We can see in detail the user's ID, groups, etc.
Get User Info using GROUPS Command
As the name implies, groups is used to show all the groups to which a user belongs.
Its syntax is:
groups user
Get User Info using FINGER Command
FINGER is used to find information about a particular user in Linux, by default it is not installed in many Linux systems.
If we want to install it, we can execute one of the following commands:
sudo apt install finger (Debian / Ubuntu) sudo yum install finger (RHEL / CentOS) sudo dnf install finger (Fedora 22 & Higher)
Once installed, we proceed to execute them using the following syntax:
finger user
Finger will display a user's real name, home directory, shell, login and more information.
Get User Info using GETENT Command
GETENT is a command-line utility that retrieves entries from the nameserver switch (NSS) libraries of a system database.
To obtain the details of a user's account, we will use the passwd database and the username in the following way:
getent passwd user
Get User Info using GREP Command
The grep command is a powerful pattern search tool available on most Linux distros. We can use it to find information about a specific user of the system accounts file / etc / passwd in the following way:
grep -i user /etc/passwd
Get User Info using LSLOGINS Command
The lslogins command shows information about known users in the system, the -u parameter only shows user accounts:
lslogins -u
Get User Info using USERS Command
The users command displays the user names of all the users that are currently connected to the system, its syntax is:
users
Get User Info using WHO Command
The who command is used to show users that they are connected to the system, including the terminals from which they are connected.
who -u
Get User Info using W Command
The w command displays all the users that have logged in to the system and their respective activity:
w
Get User Info using LAST / LASTBÂ Command
The last or lastb command displays a list of the last users registered in the system. We can use only last or last -a to indicate the name of the host in the last column:
last -a
Get User Info using LASTLOG Command
The lastlog command is used to find the details of a recent login of all users or a specific user in the system.
There we can use only lastlog or lastlog -u user for a specific user:
lastlog -u user
With these alternatives it will be practical to find this type of information and have much more complete details for the administration tasks.