news 2026/1/13 13:57:25

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/1/3 13:17:53

紧急警告:错误的导出格式正毁掉你的量子实验成果,速查正确方式

第一章:紧急警告:错误的导出格式正毁掉你的量子实验成果在高精度量子计算实验中,数据导出阶段常被忽视,却可能成为整个研究链条中最致命的薄弱环节。使用不兼容或非标准化的数据格式导出量子态测量结果,会导致后续分析…

作者头像 李华
网站建设 2026/1/5 2:16:06

35 岁职场焦虑蔓延?为什么网络安全行业越老越值钱?

前几天我表弟小王来找我喝茶,聊着聊着突然问我:“老曹,你说我要不要转行做网络安全啊? 听说这行业挺赚钱的。 “我一听就笑了,这不正好最近我刚研究过这个行业吗? 我跟他说,别看现在各行各业…

作者头像 李华
网站建设 2026/1/11 14:23:53

内网渗透实战干货:12 个优质靶场平台精选,附避坑指南 + 实操技巧合集!

前言 在内网渗透学习中,“实战靶场” 是连接理论与实操的核心桥梁 —— 它能模拟真实企业内网的拓扑结构、漏洞分布和信任关系,让你在合法可控的环境中练手 “跳板机横向移动”“域控提权” 等关键技能。 以下按 “新手入门→进阶实战→专项突破” 三个…

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

50天学习FPGA第16天-verilog的模块与端口

目录 简介 目标 模块 端口 端口列表 简介 在前面学习中,我们对Verilog中的基础内容,基本约定和语法结构等有了一定的理解。在本章中,我们从Verilog的角度对模块和端口做进一步的讨论。 目标 说明Verilog模块定义中的各个组成部分,例如模块名、端口列表、参数、变量声…

作者头像 李华
网站建设 2026/1/12 17:07:57

50天学习FPGA第15天-verilog基本概念

目录 简介 目标 语法约定 空白符 注释 操作符 数字声明 字符串 标识符和关键字 数据类型 简介 本周讨论Verilog中的基本语法结构和约定,后续章节中会使用这些结构和约定。这些约定构成了Verilog语言的基本框架。Verilog模型中的数据类型与实际硬件电路中的数据存储和…

作者头像 李华