Show Logged in Users on Linux

Got a multiuser Linux system and wondering who is logged in it? Here are various ways to find that out.
Warp Terminal

If you are running a server or a system that is being used by multiple users, you may want to find the users who are logged in currently.

And the easiest way to do that is by executing the users command:

users
find the logged in users in Ubuntu

And as you can see, it gets the list of the currently logged-in users.

But there are other ways that give more detailed output than just listing the logged-in users.

Want to know what they are? Here you have it.

How to find logged-in users in Linux

There are multiple ways to find the logged-in users in Linux and I will be sharing the ones that provide more detailed output like IP address, time of logging in, etc.

So let's start with the first one.

Using the w command

This command gives you information like log-in time, IP, the terminal used to log in, and much more.

And execution is also quite simple. All you have to do is execute a single-character command:

w
use w command to know the logged in users in Linux

Here,

  • USER indicates the username of the logged-in user.
  • TTY indicates which terminal was used to log in. Here, tty7 indicates that the user has used the native terminal to log in and pts indicates the user has logged in via SSH.
  • FROM is where you'll find the IP of the remotely logged-in used.
  • LOGIN@ indicates the time of logging in.
  • IDLE shows the time the user is in an idle state (doing nothing).
  • JCPU is a time used by all the processes attached to the current tty.
  • PCPU is a time taken by the current process and mentioned in the WHAT field.
  • WHAT indicates the current process.

Pretty detailed. Isn't it?

πŸ’‘
You may use the last command to see the recent logins to the system. It will show both current and recently logged in details.

Using the who command

This is yet another way to list logged-in users and can be suitable for those who want to have less detailed output compared to what the w command gave.

The command execution is quite simple:

who -H
use who command to know the logged in users

The -H option prints the heading which makes it easier to understand the output. The heading elements are:

  • NAME show the username of the logged-in user
  • LINE indicates which terminal was used to log in
  • TIME column shows the time of logging in
  • COMMENT is where you'll find the IP of remote logins

I know the column names are pretty different and do not make much sense but that's what the who command offers!

New Book: Efficient Linux at the Command Line

Pretty amazing Linux book with lots of practical tips. It fills in the gap, even for experienced Linux users. Must have in your collection.

Get it from Amazon

Using the finger utility

If you want the most detailed output, the finger utility will do the job as it is a user information utility so if you added extra details while adding users in Linux, they will be reflected here!

But it does not come pre-installed and you'd have so here's how you install it.

For Ubuntu/Debian base:

sudo apt install finger

For Arch Linux:

yay -S netkit-bsd-finger

For Fedora/RHEL:

sudo dnf install finger

Once you are done with the installation, all you have to do is execute the following command:

finger 
use finger command to find the logged in users

And as you can see, there are two extra rows for Office and Phone, so if you added extra details while creating a user, it should be reflected here!

Want to log out inactive users?

Once you know which users are inactive, you may want to log them out. So how do you do that? Here's a detailed guide:

How to Automatically Logout Inactive Linux Users
Here are two ways you can automatically log out idle users from your Linux system.

I hope you will find this informative. And if you have any queries, feel free to ask in the comments.

About the author
Sagar Sharma

Sagar Sharma

A software engineer who loves to write about his experience with Linux. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.