news 2026/6/15 6:29:23

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

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
12 Ways to Find User Account Info and Login Details in Linux

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

If you want to add or create users in Linux, use the useradd command, and to modify or change any attributes of an already created user account, use the usermod command via the command line.

You might also like:

  • How to Monitor Linux Commands Executed by Users in Linux
  • How to Monitor Linux User’s Activity with psacct or acct Tools
  • whowatch – Monitor Linux Users and Processes in Real Time
  • MimiPenguin – Display (Hack) Login Passwords of Linux Users

We’ll start by looking at 12 useful commands to find a user’s account information, then proceed to explain commands to view login details in the Linux system.

Table of Contents

  • 1. id Command – Show User and Group IDs
  • 2. groups Command – View User Group Memberships
  • 3. finger Command – Show User Information
  • 4. getent Command – Fetch User Info from System Database
  • 5. grep Command – Search for Patterns or Specific Text in Files
  • 6. lslogins Command – Display User Information in Linux
  • 7. users Command – List Current Logged-In Users on Linux
  • 8. who Command – Show Information Of Currently Logged-In Users
  • 9. w Command – Show Currently Logged-In User Activity
  • 10. last Command – Show Most Recent Login Session
  • 11. lastb Command – Show Failed Login Attempts
  • 12. lastlog Command – List User Login Information

1. id Command – Show User and Group IDs

Theidis a simple command line utility for displaying a real and effective user and group IDs identity information for the current user or specified user.

$ id tecmint

View User and Group ID’s of Current User

2. groups Command – View User Group Memberships

Thegroupscommand is used to display the group memberships for a user. It lists all the groups that a user belongs to, including both primary and supplementary groups.

$ groups tecmint

Check User Groups in Linux

3. finger Command – Show User Information

Thefingercommand is used to search for information about a user on Linux, which includes detailed information about a specific user or a list of users, including their login name, real name, terminal, idle time, login time, and other relevant details.

Thefingercommand doesn’t come pre-installed on many Linux distributions, you need to install it using your default package manager as shown.

$ sudo apt install finger [OnDebian, Ubuntu and Mint] $ sudo yum install finger [OnRHEL/CentOS/FedoraandRocky/AlmaLinux] $ sudo emerge -a sys-apps/finger [OnGentoo Linux] $ sudo apk add finger [OnAlpine Linux] $ sudo pacman -S finger [OnArch Linux] $ sudo zypper install finger [OnOpenSUSE]

It shows a user’s real name; home directory; shell; login: name, time; and so much more as shown below.

$ finger tecmint

Check User Info in Linux

4. getent Command – Fetch User Info from System Database

Thegetentcommand is used to retrieve information from various databases, including the system user and group databases. It can be used to retrieve information about users, groups, hosts, networks, protocols, and other system entities that are stored in database files like/etc/passwd,/etc/group,/etc/hosts, etc.

To get a user’s account details, use thepasswddatabase and theusernameas follows.

$ getent passwd tecmint

Fetch User Info in Linux

5. grep Command – Search for Patterns or Specific Text in Files

The grep command is a powerful command used to search for patterns or specific text in files. It allows you to filter and extract lines from text based on matching patterns. The name “grep” stands for “Global Regular Expression Print“.

You might also like:

  • 11 Advanced Linux Grep Command Examples
  • How to Use fgrep Command to Search for Strings in Linux
  • egrep – Search for Specific Strings in Multiple Files

You can usegrepto find information about a specific user from the system accounts file:/etc/passwdas shown below.

$ grep -i tecmint /etc/passwd

Grep – Fetch User Info in Linux

6. lslogins Command – Display User Information in Linux

Thelsloginscommand shows information about known users in the system, which typically includes details such as the username, UID (User ID), GID (Group ID), home directory, shell, last login time, and more, depending on the options used and the system configuration.

$ lslogins -u tecmint $ lslogins -u

Display User Info in Linux

7. users Command – List Current Logged-In Users on Linux

Theuserscommand is used to display the list of currently logged-in users on the Linux system.

$ users

Show Current Logged in Users in Linux

8. who Command – Show Information Of Currently Logged-In Users

Thewhocommand is used to display users who are logged on to the system, including the username, terminal, login time, and remote host from which the user is logged in.

$ who -u

Show Current Logged-in Users

9. w Command – Show Currently Logged-In User Activity

Thewcommand shows a summary of the currently logged-in users and their activity, which displays the login session, including the username, terminal, login time, idle time, JCPU (total CPU time used by all processes), PCPU (CPU time used by the current process), and the command or process running on the terminal.

$ w

Show Currently Logged-In User Activity

10. last Command – Show Most Recent Login Session

Thelastcommand displays a list of the most recent login sessions, which includes information about the users who have logged in, their login times, and the terminals or remote hosts they used for login.

$ last

Show Most Recent Login Sessions

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

$ last -ap now

List Most Recent User Logins

11. lastb Command – Show Failed Login Attempts

Thelastbcommand is used to display a list of the last failed login attempts on the system. It reads from the system log file that records failed login attempts, typically stored in /var/log/btmp.

$ lastb

Show Failed Login Attempts in Linux

12. lastlog Command – List User Login Information

lastlog commandis used to find the details of the most recent login information for all users or a specific user on the system, which provides details about the last login time and location for each user.

$ lastlog OR $ lastlog -u tecmint

List User Login Information

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

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/14 10:29:27

Pytest——》文件路径处理

1、层级结构2、文件路径获取:configimport os.pathclass Config(object):project_path os.path.split(os.path.split(__file__)[0])[0] # __file__获取当前文件的绝对路径if __name__ __main__:print(os.path.split(os.path.split(__file__)[0])[0])print(os.pat…

作者头像 李华
网站建设 2026/6/15 13:52:13

相关向量机和特征选取技术在短期负荷预测中的应用附Matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,擅长数据处理、建模仿真、程序设计、完整代码获取、论文复现及科研仿真。🍎 往期回顾关注个人主页:Matlab科研工作室🍊个人信条:格物致知,完整Matlab代码及仿真咨询…

作者头像 李华
网站建设 2026/6/15 13:54:28

电信网络专线如何选择,才能满足企业需求?

在当今这个信息爆炸的时代,企业的日常运营越来越依赖于高效稳定的网络连接。想象一下,如果一家公司的视频会议因为网络不稳定而频繁卡顿,或者数据传输速度慢得让人抓狂,那简直是一场灾难。因此,选择合适的电信网络专线…

作者头像 李华
网站建设 2026/6/15 14:15:22

Springboot萌宠之家零售网站zp5x9(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。

系统程序文件列表项目功能:用户,宠物信息,宠物商品,商品分类,新品信息,热销商品开题报告内容SpringBoot萌宠之家零售网站开题报告一、选题背景与意义1.1 选题背景随着社会经济的快速发展和居民生活水平的显著提升,宠物经济在全球范围内呈现出蓬勃发展的态…

作者头像 李华
网站建设 2026/6/11 1:37:24

Springboot民宿管理系统agq9s(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。

系统程序文件列表 项目功能:用户,房间类型,房间信息,房间预订,取消预订,民宿活动,民宿信息 开题报告内容 SpringBoot民宿管理系统开题报告 一、选题背景与意义 1.1 选题背景 随着共享经济与旅游业的深度融合,民宿行业在全球范围内呈现爆发式增长。据…

作者头像 李华