Simple Ways to Find User Account Info and Login Details in Linux
In this article, we will learn the Simple ways to find User Account info and Login details in Linux. Here we’ll portray commands to get a user’s account details, show login details just as the thing users are doing on the system.
On the off chance that you need to add users in Linux, use the
useradd utility, and to modify or change any attributes of an all-around made user account, use the
usermod by means of the command line as clarified in the following guides:
We’ll begin by seeing commands to discover a user’s account data, at that point continue to disclose commands to see login details.
1. id Command
id is a basic command-line utility for showing a genuine and powerful user and group IDs as follows.
$ id itsmarttricks uid=1000(itsmarttricks) gid=1000(itsmarttricks) groups=1000(itsmarttricks),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),130(sambashare)
2. groups Command
groups a command is used to show all the groups a user has a place with like this.
$ groups itsmarttricks itsmarttricks : itsmarttricks adm cdrom sudo dip plugdev lpadmin sambashare
3. finger Command
finger the command is used to look through the information about a user on Linux. It doesn’t come pre-installed on numerous Linux systems.
To install it on your system, run this command on the terminal.
$ sudo apt install finger #Debian/Ubuntu $ sudo yum install finger #RHEL/CentOS $ sudo dnf install finger #Fedora 22+
It shows a user’s genuine name; home directory; shell; login: name, time; thus considerably more as below.
$ finger itsmarttricks Login: itsmarttricks Name: itsmarttricks Directory: /home/itsmarttricks Shell: /bin/bash On since Fri Jan 22 10:39 (IST) on tty8 from :0 2 hours 1 minute idle No mail. No Plan.
4. getent Command
getent is a command-line utility for fetching entries from Name Service Switch (NSS) libraries from a particular system database.
To get a user’s account details, use the passwd database and the username as follows.
$ getent passwd itsmarttricks itsmarttricks:x:1000:1000:itsmarttricks,,,:/home/itsmarttricks:/bin/bash
5. grep Command
grep a command is an incredible example looking through apparatus accessible on most if not all Linus systems. You can utilize it to discover data about a particular user from the system accounts file: /etc/passwd as demonstrated beneath.
$ grep -i itsmarttricks /etc/passwd itsmarttricks:x:1000:1000:itsmarttricks,,,:/home/itsmarttricks:/bin/bash
Also Read – Best Linux Grep Command Examples
6. lslogins Command
lslogins command shows information about known users in the system, the – u flag just shows user accounts.
$ lslogins -u UID USER PROC PWD-LOCK PWD-DENY LAST-LOGIN GECOS 0 root 144 root 1000 itsmarttricks 70 10:39:07 itsmarttricks,,, 1001 aaronkilik 0 1002 john 0 John Doo
7. users Command
users command shows the usernames of all users as of now logged on the system like so.
$ users itsmarttricks aaron
8. who Command
who command’s identity is used to show users who are logged on the system, including the terminals they are associating with.
$ who -u itsmarttricks tty8 2021-01-22 10:39 02:09 2067 (:0)
9. w Command
w command shows all users who are logged on the system and what they are doing.
$ w 12:46:54 up 2:10, 1 user, load average: 0.34, 0.44, 0.57 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT itsmarttricks tty8 :0 10:39 2:10m 4:43 0.46s cinnamon-sessio
10. last or lastb commands
last/lastb commands show a rundown of the last logged-in users on the system.
$ last OR $ last -a #show hostname on the last column
List of Last Logged Users
itsmarttricks tty8 Fri Jan 22 10:39 gone - no logout :0 reboot system boot Fri Jan 22 10:36 still running 4.4.0-21-generic itsmarttricks tty8 Thu Jan 21 10:44 - down (06:56) :0 reboot system boot Thu Jan 21 10:42 - 17:40 (06:58) 4.4.0-21-generic itsmarttricks tty8 Wed Jan 20 10:19 - down (06:50) :0 reboot system boot Wed Jan 20 10:17 - 17:10 (06:52) 4.4.0-21-generic itsmarttricks pts/14 Tue Jan 19 15:15 - 15:16 (00:00) tmux(14160).%146 itsmarttricks pts/13 Tue Jan 19 15:15 - 15:16 (00:00) tmux(14160).%145 ...
To show all the users who were available at a predefined time, use the
- p option as follows.
$ last -ap now itsmarttricks tty8 Fri Jan 22 10:39 gone - no logout :0 reboot system boot Fri Jan 22 10:36 still running 4.4.0-21-generic wtmp begins Fri Jan 1 16:23:02 2021
11. lastlog Command
lastlog command is used to discover the details of a new login of all users or of a given user as follows.
$ lastlog OR $ lastlog -u itsmarttricks #show lastlog records for specific user itsmarttricks
Records of Recent Logged Users
Username Port From Latest root **Never logged in** kernoops **Never logged in** pulse **Never logged in** rtkit **Never logged in** saned **Never logged in** usbmux **Never logged in** mdm **Never logged in** itsmarttricks pts/1 127.0.0.1 Fri Jan 6 16:50:22 +0530 2021 ..
That’s all, In this article, we have explained the Simple Ways to Find User Account Info and Login Details in Linux. I hope you enjoy this article. If you like this article, then just share it. If you have any questions about this article, please comment.