• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

11 Ways to Find User Account Info and Login Details in Linux

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
42
VIEWS
Share on FacebookShare on Twitter

Contents

  1. 1. id Command
  2. 2. groups Command
  3. 3. finger Command
  4. 4. getent Command
  5. 5. grep Command
  6. 6. lslogins Command
  7. 7. users Command
  8. 8. who Command
  9. 9. w Command
  10. 10. last or lastb commands
  11. 11. lastlog Command

This article will show you eleven useful ways to find the information about users on a Linux system. Here we’ll describe commands to get a user’s account details, show login details as well as what users are doing on the system.

Read Also: How to Monitor Linux Commands Executed by System Users in Real-time

If you want to add users in Linux, use the useradd utility, and to modify or change any attributes of a already created user account, use the usermod via the command line as explained in the following guides:

  1. 15 Useful Practical Examples on ‘useradd’ Command
  2. 15 Useful Practical Examples on ‘usermod’ Command

We’ll start by looking at commands to find a user’s account information, then proceed to explain commands to view login details.

1. 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.

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 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.

$ getent passwd tecmint

tecmint:x:1000:1000:TecMint,,,:/home/tecmint:/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 tecmint /etc/passwd

tecmint:x:1000:1000:TecMint,,,:/home/tecmint:/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 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             [email protected]   IDLE   JCPU   PCPU WHAT
tecmint  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
tecmint  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
tecmint  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
tecmint  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
tecmint  pts/14       Tue Sep 19 15:15 - 15:16  (00:00)     tmux(14160).%146
tecmint  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

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

That’s it! If you know any other command-line trick or command to view user account details do share with us.

You’ll find these related article so useful:

  1. How to Manage Users and Groups in Linux
  2. How to Delete User Accounts with Home Directory in Linux
  3. 3 Ways to Change Default User Shell in Linux
  4. How to Block or Disable User Logins in Linux

In this article, we’ve explained various ways to find information about users and login details on a Linux system. You can ask any questions or share your thoughts via the feedback form below.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

How to Fix Yum Error: Database Disk Image is Malformed

Next Post

How to Install ‘locate Command’ to Find Files in Linux

Next Post

How to Install ‘locate Command’ to Find Files in Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet