Tutorials

How To: Show User Information In The Linux Terminal

There comes a time in many Linux journeys when you want to know how to show user information in the Linux terminal. Well, if you’ve been waiting for such an article, this article is for you. After all, knowing about the various users might be important information for you.

You may not realize this, but your Linux system has all sorts of users. They belong to varied groups, sometimes more than one group at a time. Unless you’re already familiar with this subject, you probably have more users than you realize. 

That’s perfectly okay. It’s entirely normal to have different users. Linux is a user-oriented operating system. Users have varied permissions and can perform different tasks based on those permissions. 

This actually shouldn’t be a complicated article. It’s just a couple of commands, though the command may not be well-known among the newer Linux users. New users should familiarize themselves with the concepts of a multi-user system and with groups.

Anyhow, you shouldn’t need to install anything. The tools we’ll be using should be installed by default. You will need an open terminal. So, you have been warned. After all, it was right there in the title!

lslogins:

The tool we’ll expose you to today is ‘lslogins‘, which should be installed by default. You can verify that lslogins is installed with this command:

lslogins --v

And, if you check the man page (with man lslogins) you’ll see this:

lslogins – display information about known users in the system

So, sure enough, that looks like it’s the correct tool for the job. Our goal is to show user information in the Linux terminal. This looks like a good way to go about it.

Show User Information In The Linux Terminal:

Yes, we’re doing this in the terminal. You can frequently open your terminal by pressing CTRL + ALT + T. Otherwise, you’ll find a terminal emulator somewhere within your application menu. It’s likely to be in the admin section of said menu.

With your terminal open, you can start with the basics. That is, we’re going to show all the known users with the lslogins command. That syntax is so simple.

lslogins

You’ve got a lot of users. You may not know it yet, but you do. Here’s an example output from my system:

$ lslogins
  UID USER       PROC PWD-LOCK PWD-DENY  LAST-LOGIN GECOS
    0 root        149                               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 (
  100 systemd-network
                    0                               systemd Network Management,,
  101 systemd-resolve
                    1                               systemd Resolver,,,
  102 messagebus    1                               
  103 systemd-timesync
                    1                               systemd Time Synchronization
  104 syslog        1                               
  105 _apt          0                               
  106 tss           0                               TPM software stack,,,
  107 rtkit         1                               RealtimeKit,,,
  108 systemd-coredump
                    0                               systemd Core Dumper,,,
  109 kernoops      2                               Kernel Oops Tracking Daemon,
  110 uuidd         0                               
  111 cups-pk-helper
                    0                               user for cups-pk-helper serv
  112 lightdm       0                               Light Display Manager
  113 tcpdump       0                               
  114 speech-dispatcher
                    0                               Speech Dispatcher,,,
  115 avahi-autoipd
                    0                               Avahi autoip daemon,,,
  116 usbmux        0                               usbmux daemon,,,
  117 nm-openvpn    0                               NetworkManager OpenVPN,,,
  118 geoclue       0                               
  119 dnsmasq       0                               dnsmasq,,,
  120 pulse         0                               PulseAudio daemon,,,
  121 _flatpak      0                               Flatpak system-wide installa
  122 avahi         2                               Avahi mDNS daemon,,,
  123 saned         0                               
  124 colord        1                               colord colour management dae
  125 fwupd-refresh
                    0                               fwupd-refresh user,,,
  126 hplip         0                               HPLIP system user,,,
  127 sssd          0                               SSSD system user,,,
  128 vnstat        1                               vnstat daemon,,,
 1000 kgiii       197                   Dec23/13:58 kgiii,,,
65534 nobody        0                               nobody

Now, that’s all well and good.

But…

Let’s say you only want to show user information about one single user. That’s fine and you can do that in a variety of ways. You can also do it just as easily with the lslogins command, simply by using the -u flag. 

The syntax is as follows:

lslogins -u <user>

An example output might look like this:

$  lslogins -u root
KZAK>>> alloc '0x557cdffe09d0' for root
KZAK>>> alloc '0x557cdffe09f0' for root
Username:                           root                                
UID:                                0                                   
Gecos field:                        root                                
Home directory:                     /root                               
Shell:                              /bin/bash                           
No login:                           no                                  
Primary group:                      root                                
GID:                                0                                   
Last terminal:                                                          
Last hostname:                                                          
Running processes:                  149   

And there’s the information about the root user. You can try with your username and get information about things like the groups you belong to and more. Go ahead and give it a shot, you won’t break anything. I promise you won’t break anything with this command!

Closure:

You never know when you’re going to want to show user information in the terminal. It is useful information, especially when debugging things like permission errors. You may find you need to add yourself to a group or things like that. So, store this command away in your mental bank and save it for when you need this information.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Recent Posts

Enable/Disable Your Network Interface

Today we'll cover one way to enable or disable your network interface in the Linux…

7 months ago

Check Your NIC Speed In The Terminal

Today's exercise is a nice and simple exercise where we check your NIC speed in…

7 months ago

Easily Monitor Your Wireless Connection

Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…

7 months ago

Count The Files In A Directory

I think I've covered this before with the ls command but this time we'll count…

7 months ago

Get System Information With The ‘uname’ Command In Linux

Today we'll be learning about a basic Linux command that's known as 'uname' and it…

7 months ago

hardinfo Has Been Rebooted As hardinfo2

If you've used hardinfo in the past, it may interest you to know that hardinfo…

7 months ago