Information about linux user

How to Find User Account Info and Login Details in Linux?

For the sysadmins, it is routine to monitor user details like who are active and who are not, who logged in in last 2 days, which users belong to a given group etc etc. To help these requirements, Linux provides below list of commands which can be used to gather various types of information about the users.

id Command

It gives the id details of users including the group id along with the secondary group IDs and names of a user choosen by the system. But you also ask for a specific user’sdeatils by giving the userid value in the command.

ubuntu@ubuntu:~$ id ubuntu@ubuntu:~$ id 2112

Running the above code gives us the following result:

uid=1000(ubuntu) gid=1000(ubuntu) groups=1000(ubuntu),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare) uid=2112(uname1) gid=3421(uname1) groups=3421(uname1)

groups

It displays the group names the currently logged in user belongs to.

Running the above code gives us the following result −

ubuntu adm cdrom sudo dip plugdev lpadmin sambashare

getnet

This command looks into passed file and gets the user details form there.

ubuntu@ubuntu:~$ getent passwd

Running the above code gives us the following result −

root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin …… ………

lslogins

The lslogins command displays details of the known users of the system.

Running the above code gives us the following result −

UID USER PROC PWD-LOCK PWD-DENY LAST-LOGIN GECOS 0 root 135 root 1000 ubuntu 70 23:04:25 ubuntu16LTS. 2112 uname1 0 storefront 9002 uname4 0 HR

w

It displays the current users logged in to the system and the processes they are running.

Running the above code gives us the following result −

08:13:17 up 12:26, 1 user, load average: 0.00, 0.00, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT ubuntu tty7 :0 23:04 12:58m 1:23 0.34s /sbin/upstart –user

Источник

11 способов найти информацию об учетной записи пользователя и данные для входа в Linux

Эта статья покажет вам одиннадцать полезных способов поиска информации о пользователях в системе Linux. Здесь мы опишем команды для получения данных учетной записи пользователя, отображения данных для входа, а также того, что пользователи делают в системе.

Если вы хотите добавить пользователей в Linux, используйте usermod через командную строку, как описано в следующих руководствах:

  1. 15 полезных практических примеров команды useradd
  2. 15 полезных практических примеров использования команды usermod
Читайте также:  Bluetooth adapters for linux

Мы начнем с рассмотрения команд для поиска информации об учетной записи пользователя, а затем перейдем к объяснению команд для просмотра данных для входа.

1. Идентификационная команда

id — это простая утилита командной строки для отображения реальных и эффективных идентификаторов пользователей и групп следующим образом.

$ 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 используется для отображения всех групп, к которым принадлежит пользователь.

$ groups tecmint tecmint : tecmint adm cdrom sudo dip plugdev lpadmin sambashare

3. Команда пальца

Команда finger используется для поиска информации о пользователе в Linux. Во многих системах Linux он не устанавливается отдельно.

Чтобы установить его в своей системе, запустите эту команду в терминале.

$ sudo apt install finger #Debian/Ubuntu $ sudo yum install finger #RHEL/CentOS $ sudo dnf install finger #Fedora 22+

показывает настоящее имя пользователя; домашний каталог; оболочка; логин: имя, время; и многое другое, как показано ниже.

$ 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

getent — это утилита командной строки для извлечения записей из библиотек Name Service Switch (NSS) из определенной системной базы данных.

Чтобы получить данные учетной записи пользователя, используйте базу данных passwd и имя пользователя следующим образом.

$ getent passwd tecmint tecmint:x:1000:1000:TecMint. /home/tecmint:/bin/bash

5. Команда grep

Команда grep — это мощный инструмент поиска шаблонов, доступный в большинстве, если не во всех системах Linux. Вы можете использовать его для поиска информации о конкретном пользователе в файле системных учетных записей: /etc/passwd, как показано ниже.

$ grep -i tecmint /etc/passwd tecmint:x:1000:1000:TecMint. /home/tecmint:/bin/bash

6. Команда lslogins

команда lslogins показывает информацию об известных пользователях в системе, флаг -u отображает только учетные записи пользователей.

$ 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 показывает имена всех пользователей, которые в данный момент вошли в систему.

$ users tecmint aaron

8. кто командует

команда who используется для отображения пользователей, которые вошли в систему, включая терминалы, с которых они подключаются.

$ who -u tecmint tty8 2017-09-22 10:39 02:09 2067 (:0)

9. Команда w

команда w показывает всех пользователей, вошедших в систему, и то, что они делают.

$ w 12:46:54 up 2:10, 1 user, load average: 0.34, 0.44, 0.57 USER TTY FROM IDLE JCPU PCPU WHAT tecmint tty8 :0 10:39 2:10m 4:43 0.46s cinnamon-sessio

10. последняя или последняяb команды

Команды last/lastb отображают список последних пользователей, выполнивших вход в систему.

$ last OR $ last -a #show hostname on the last column
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 .

Чтобы показать всех пользователей, которые присутствовали в указанное время, используйте параметр -p следующим образом.

$ 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

команда lastlog используется для поиска сведений о недавнем входе в систему всех пользователей или данного пользователя следующим образом.

$ lastlog OR $ lastlog -u tecmint #show lastlog records for specific user tecmint
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 ..

Вот и все! Если вы знаете какой-либо другой трюк или команду командной строки для просмотра сведений об учетной записи пользователя, поделитесь с нами.

Читайте также:  Touch screen with linux driver

Вы найдете эти связанные статьи очень полезными:

  1. Как управлять пользователями и группами в Linux
  2. Как удалить учетные записи пользователей с помощью домашнего каталога в Linux
  3. 3 способа изменить оболочку пользователя по умолчанию в Linux
  4. Как заблокировать или отключить вход пользователей в систему в Linux

В этой статье мы объяснили различные способы поиска информации о пользователях и данных для входа в систему Linux. Вы можете задать любые вопросы или поделиться своими мыслями через форму обратной связи ниже.

Источник

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:

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.

1. id Command – Show User and Group IDs

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

View User and Group ID

2. groups Command – View User Group Memberships

The groups command 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.

Check User Groups in Linux

3. finger Command – Show User Information

The finger command 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.

The finger command 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 [On Debian, Ubuntu and Mint] $ sudo yum install finger [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] $ sudo emerge -a sys-apps/finger [On Gentoo Linux] $ sudo apk add finger [On Alpine Linux] $ sudo pacman -S finger [On Arch Linux] $ sudo zypper install finger [On OpenSUSE]

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

Check User Info in Linux

4. getent Command – Fetch User Info from System Database

The getent command 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.

Читайте также:  Linux mint обзор оболочек

To get a user’s account details, use the passwd database and the username as follows.

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:

You can use grep to find information about a specific user from the system accounts file: /etc/passwd as shown below.

Grep - Fetch User Info in Linux

6. lslogins Command – Display User Information in Linux

The lslogins command 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

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

Show Current Logged in Users in Linux

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

The who command 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.

Show Current Logged in Users

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

The w command 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.

Show Currently Logged-In User Activity

10. last Command – Show Most Recent Login Session

The last command 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.

Show Most Recent Login Sessions

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

List Most Recent User Logins

11. lastb Command – Show Failed Login Attempts

The lastb command 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.

Show Failed Login Attempts in Linux

12. lastlog Command – List User Login Information

lastlog command is 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.

You might also like:

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.

Источник

Оцените статью
Adblock
detector