1. id Command

id is a simple command line utility for displaying a real and effective user and group IDs as follows.

$ id ucartz 
uid=1000(ucartz) gid=1000(ucartz) groups=1000(ucartz),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),130(sambashare)

2. groups Command

groups command is used to show all the groups a user belongs to like this.

$ groups ucartz
ucartz : ucartz adm cdrom sudo dip plugdev lpadmin sambashare

3. finger Command

finger command is used to search information about a user on Linux. It doesn’t come per-installed on many 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 real name; home directory; shell; login: name, time; and so much more as below.

$ finger ucartz
Login: ucartz        			Name: ucartz
Directory: /home/ucartz            	Shell: /bin/bash
On since Fri Sep 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 specific system database.

To get a user’s account details, use the passwd database and the username as follows.

$ getent passwd ucartz
ucartz:x:1000:1000:ucartz,,,:/home/ucartz:/bin/bash

5. grep Command

grep command is a powerful pattern searching tool available on most if not all Linus systems. You can use it to find information about a specific user from the system accounts file: /etc/passwd as shown below.

$ grep -i ucartz /etc/passwd
ucartz:x:1000:1000:ucartz,,,:/home/ucartz:/bin/bash

6. lslogins Command

lslogins command shows information about known users in the system, the -u flag only displays user accounts.

$ lslogins -u
UID USER       PROC PWD-LOCK PWD-DENY LAST-LOGIN GECOS
0 root        144                              root
1000 ucartz      70                     10:39:07 ucartz,,,
1001 arun    0                              

7. users Command

users command shows the usernames of all users currently logged on the system like so.

$ users
ucartz
aaron

8. who Command

who command is used to display users who are logged on the system, including the terminals they are connecting from.

$ who -u
ucartz  tty8         2017-09-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
ucartz  tty8     :0               10:39    2:10m  4:43   0.46s cinnamon-sessio

10. last or lastb commands

last/lastb commands displays a list of last logged in users on the system.

$ last 
OR
$ last -a   #show hostname on the last column
List of Last Logged Users
ucartz  tty8         Fri Sep 22 10:39    gone - no logout  :0
reboot   system boot  Fri Sep 22 10:36   still running      4.4.0-21-generic
ucartz  tty8         Thu Sep 21 10:44 - down   (06:56)     :0
reboot   system boot  Thu Sep 21 10:42 - 17:40  (06:58)     4.4.0-21-generic
ucartz  tty8         Wed Sep 20 10:19 - down   (06:50)     :0
reboot   system boot  Wed Sep 20 10:17 - 17:10  (06:52)     4.4.0-21-generic
ucartz  pts/14       Tue Sep 19 15:15 - 15:16  (00:00)     tmux(14160).%146
ucartz  pts/13       Tue Sep 19 15:15 - 15:16  (00:00)     tmux(14160).%145
...

To show all the users who were present at a specified time, use the -p option as follows.

$ last -ap now
ucartz  tty8         Fri Sep 22 10:39    gone - no logout  :0
reboot   system boot  Fri Sep 22 10:36   still running      4.4.0-21-generic
wtmp begins Fri Sep  1 16:23:02 2017

11. lastlog Command

lastlog command is used to find the details of a recent login of all users or of a given user as follows.

$ lastlog  
OR
$ lastlog -u ucartz 	#show lastlog records for specific user ucartz
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**
ucartz          pts/1    127.0.0.1        Fri Jan  6 16:50:22 +0530 2017
..

That’s it!

Was this answer helpful? 0 Users Found This Useful (0 Votes)