Posted: 13 January 2020. At: 10:22 AM. This was 4 years ago. Post ID: 13963
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

How to get information about a user on Linux with the command line.

It is easy to get comprehensive information about a user on Linux by using the command line. I will show you how to see password expiry information and other details.

This example shows the use of the chage command to retrieve password expiry information.

4.4 Mon Jan 13 jason@Yog-Sothoth 0: $ sudo chage -l jason
Last password change					: Aug 26, 2019
Password expires					: never
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 99999
Number of days of warning before password expires	: 7

This shows the details about an account and when the password expires.

See how long you have been logged in on your system.

4.4 Mon Jan 13 jason@Yog-Sothoth 0: $ finger -lmps $LOGNAME | grep "On since"
On since Mon Jan 13 08:05 (AEDT) on :1 from :1 (messages off)

List all users that are actual Linux desktop users, i.e with a UID bigger than 1000.

4.4 Mon Jan 13 jason@Yog-Sothoth 0: $ lslogins | perl -ne 'print if grep {$_>1000} /(\d{3,})/g'
     1001 justin                 0                              Jason,,,
     1002 trump                  0                              Donald Trump,101,,
     1003 test5                  0                              
     1004 obama                  0                              Barak Obama
     1005 mrpres                 0                              Barak Obama
    64055 libvirt-qemu           0                              Libvirt Qemu,,,
    65534 nobody                 0                              nobody
400000000 jimkirk                0

Display information about various users with the lslogins command.

4.4 Mon Jan 13 jason@Yog-Sothoth 0: $ lslogins --logins=jason,trump
 UID USER  PROC PWD-LOCK PWD-DENY LAST-LOGIN GECOS
1000 jason   75                        08:05 Linux User,,,
1002 trump    0                              Donald Trump,101,,

How to display a lot of information about a single user.

4.4 Mon Jan 13 jason@Yog-Sothoth 0: $ lslogins jason
Username:                           jason                               
UID:                                1000                                
Gecos field:                        Linux User,,,                       
Home directory:                     /home/jason                         
Shell:                              /bin/bash                           
No login:                           no                                  
Primary group:                      jason                               
GID:                                1000                                
Supplementary groups:               adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare,libvirt,wireshark
Supplementary group IDs:            4,24,27,30,46,120,129,140,143       
Last login:                         08:05                               
Last terminal:                      :1                                  
Last hostname:                      :1                                  
Hushed:                             no                                  
Running processes:                  75                                  
 
Last logs:
10:13 /usr/lib/gdm3/gdm-x-session[6216]: No backlights were found on your system
10:15 /usr/lib/gdm3/gdm-x-session[6216]: restack_win(0x0141afc1, 0x0141afd1): Failed to found new above window.

These tips should be very useful for a Linux user that needs to manage user accounts on Linux. This should get you off to a good start managing accounts on a server.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.