Professional Documents
Culture Documents
Linux User Account
Linux User Account
id Command
id is a simple command line utility for displaying a real and effective user and group IDs as follows.
$ id tecmint
uid=1000(tecmint) gid=1000(tecmint)
groups=1000(tecmint),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 tecmint
tecmint : tecmint 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.
It shows a user’s real name; home directory; shell; login: name, time; and so much more as below.
$ finger tecmint
Login: tecmint Name: TecMint
Directory: /home/tecmint 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.
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.
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 tecmint 70 10:39:07 TecMint,,,
1001 aaronkilik 0
1002 john 0 John Doo
7. users Command
users command shows the usernames of all users currently logged on the system like so.
$ users
tecmint
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
tecmint 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
tecmint tty8 :0 10:39 2:10m 4:43 0.46s cinnamon-sessio
$ last
OR
$ last -a #show hostname on the last column
To show all the users who were present at a specified time, use the -p option as follows.
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 tecmint #show lastlog records for specific user tecmint
That’s it! If you know any other command-line trick or command to view user account details do share
with us.