当前位置: 首页 > news >正文

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.

http://www.zskr.cn/news/117609.html

相关文章:

  • 政府网站与政务新媒体检查指标抽查通报如何面对
  • Windows系统文件xinput1_3.dll找不到问题 下载修复
  • ABAP直连外部HANA数据库实操指南(DBCO配置+ECC/S/4实现方案)
  • 没公网 IP 也能远程控制!Linux 用 rdesktop+cpolar 轻松搞定
  • 从 paperxie 到细分场景:7 款差异化 AI 开题报告工具如何破解不同专业的开题卡壳难题?
  • 11.4
  • 你还在为Cirq补全发愁?3步完成IDE环境与框架版本精准对齐(附配置清单)
  • 2020级秦zhengdan经验分享
  • Oracle等待事件:性能诊断与优化的核心指南
  • 友为软件合同电子签署落地实践:从表单配置到双章归档的全流程解析
  • 11.10
  • 从 “开题框架卡一周” 到 “3 步匹配学术规范:paperxie 开题报告功能如何适配不同学科的开题逻辑?
  • 扩容U盘,资料毁灭盘
  • DOM 与 BOM:前端开发者必须分清的两大核心对象
  • 步进电机的抖动和噪音从何而来?看ADI Trinamic步进电机驱动芯片如何“对症下药”
  • AI伦理治理:在创新与规范之间寻找平衡之道
  • C++医学图像处理经典ITK库用法详解<五>: 数学运算与变换模块功能
  • UTP测试系统为家电及智能家居产品打造高效、合规、体验至上的验证体系
  • Webpack5优化的“双引擎”
  • 基于Springboot+Vue超市仓库管理系统(完整源码+万字论文+答辩PPT)
  • Java毕设项目:基于SpringBoot的少儿编程在线教育网站设计与开发基于Java的scratch少儿编程学习网站系统的设计与实现(源码+文档,讲解、调试运行,定制等)
  • distro 和 ramdisk 区别
  • 运维远控工具盘点排名第一:为何大公司都选择选择ToDesk
  • 八)--工具和MCP调用
  • 【万字长文】Transformer原理图解:从小白到程序员,一文掌握大语言模型核心架构!
  • .NET 中各种程序目录获取方法的区别与使用场景
  • C语言指针详解:内存操作的核心利器
  • Java毕设项目:基于JAVA的北京市公交管理系统基于Java+Vue+SpringBoot的北京市公交管理系统(源码+文档,讲解、调试运行,定制等)
  • FreeSWITCH开启silk编码及转码
  • C++医学图像处理经典ITK库用法详解<三>: 图像配准模块功能