Terminal

Linux: display user account information

By

in

When dealing with Linux systems and user administration, it might be necessary to get information about user accounts on the system. There are multiple ways to get such information. This post summarizes some possibilities.

lslogins Command – list users and groups

The lslogins command gives you an overview of users and groups, not only regarding their account configuration but also their activity on the system.

Display information about known users in the system.

The general syntax is:

lslogins [options] [<username>]

Calling lslogins without any option will list all user details and generate such an output:

lslogins
Output
  UID USER        PROC PWD-LOCK PWD-DENY  LAST-LOGIN GECOS
    0 root         178                   Apr14/20:55 root
    1 daemon         0                               daemon
    2 bin            0                               bin
    3 sys            0                               sys
    4 sync           0                               sync
...

Adding a username without options will limit the info to this user and show such output:

lslogins mathias
Output
Username:                           mathias
UID:                                12345
Gecos field:                        Mathias L.
Home directory:                     /home/mathias
Shell:                              /bin/bash
No login:                           no
Primary group:                      users
GID:                                4000
Last login:                         12:52
Last terminal:                      pts/1
...

To get a full list of available options, you can use the --help parameter:

lslogins --help

id Command – details about users and groups

The id command can be used to show information about users and groups.

Display user and group information for each specified USER, or (if USER is not specified) for the current process.

The general syntax is:

id [option] [user]

Calling id without any option will list the user details of the current process:

id
Output
uid=12345(mathias) gid=4000(users) Gruppen=4000(users)

To get a full list of available options, you can use the --help parameter:

id --help

finger Command – show user information

The command finger can be used to show user information.

The general syntax is:

finger [options] [<user> | <user>@<host> | @<host>]

To get a full list of available options, you can use the --help parameter:

finger --help

There are more examples in the official documentation.

users Command – get logged in users

The users command displays the list of currently logged-in users on the Linux system.

The users command lists the login names of the users that are currently logged on to the system to standard output (stdout) in a compact, one-line list format.

https://www.ibm.com/docs/en/aix/7.3?topic=u-users-command

The default syntax is:

users

The result is a list of users.

Photo by Gabriel Heinzer on Unsplash



Comments

Leave a Reply

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