Posted: . At: 11:22 AM. This was 5 years ago. Post ID: 13425
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.


Get information about users on your Linux system easily.


A Linux system can have a lot of users in the /etc/passwd file. But it is easy to keep track of your users with the command line.

The lslogins command will print a listing of known users on your Linux system.

An example of the usage.

jason@jason-Virtual-Machine:~$ lslogins
  UID USER                PROC PWD-LOCK PWD-DENY LAST-LOGIN GECOS
    0 root                 112                              root
    1 daemon                 0                              daemon
    2 bin                    0                              bin
    3 sys                    0                              sys
    4 sync                   0                              sync
    5 games                  0                              games
    6 man                    0                              man
    7 lp                     0                              lp
    8 mail                   0                              mail
    9 news                   0                              news
   10 uucp                   0                              uucp
   13 proxy                  0                              proxy
   33 www-data               0                              www-data
   34 backup                 0                              backup
   38 list                   0                              Mailing List Manager
   39 irc                    0                              ircd
   41 gnats                  0                              Gnats Bug-Reporting System (admin)
  100 systemd-timesync       1                              systemd Time Synchronization,,,
  101 systemd-network        0                              systemd Network Management,,,
  102 systemd-resolve        1                              systemd Resolver,,,
  103 messagebus             1
  104 syslog                 1
  105 _apt                   0
  106 uuidd                  0
  107 avahi-autoipd          0                              Avahi autoip daemon,,,
  108 usbmux                 0                              usbmux daemon,,,
  109 rtkit                  1                              RealtimeKit,,,
  110 dnsmasq                0                              dnsmasq,,,
  111 cups-pk-helper         0                              user for cups-pk-helper service,,,
  112 speech-dispatcher      0                              Speech Dispatcher,,,
  113 kernoops               2                              Kernel Oops Tracking Daemon,,,
  114 avahi                  2                              Avahi mDNS daemon,,,
  115 saned                  0
  116 nm-openvpn             0                              NetworkManager OpenVPN,,,
  117 whoopsie               1
  118 colord                 1                              colord colour management daemon,,,
  119 hplip                  0                              HPLIP system user,,,
  120 geoclue                0
  121 pulse                  0                              PulseAudio daemon,,,
  122 gnome-initial-setup    0
  123 gdm                   33                              Gnome Display Manager
  124 sshd                   0
  999 systemd-coredump       0                              systemd Core Dumper
 1000 jason                 62                        20:38 john,,,
65534 nobody                 0                              nobody

List all users on your system that require a password to login.

jason@jason-Virtual-Machine:~$ lslogins -u -p
 UID USER  PWD-EMPTY PWD-LOCK PWD-DENY NOLOGIN HUSHED PWD-METHOD
   0 root                                    0
1000 jason                                   0      0

Display the user`s last login time.

jason@jason-Virtual-Machine:~$ lslogins -L | grep jason
 1000 jason               pts/0    192.168.1.5        20:38

List all currently logged in users on your computer system.

jason@jason-Virtual-Machine:~$ who
jason    :1           2019-07-31 20:38 (:1)
jason    pts/0        2019-07-31 20:38 (192.168.1.5)

List all home directories listed in /etc/passwd.

jason@jason-Virtual-Machine:~$ awk -F: '{ print $6}' /etc/passwd | grep "/home"
/home/syslog
/home/cups-pk-helper
/home/jason

How to use the bash shell to find all normal users listed in the /etc/passwd with a UID above 1000.

jason@jason-Virtual-Machine:~$ getent passwd {1000..60000} | awk -F: '{ print $1}'
jason

Leave a Comment

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