Linux from its core is made to have multiple users especially if we consider servers.
And there are several reasons why you want to check the currently logged-in users such as to check for unauthorized access.
The easiest way to check the logged-in users in your Ubuntu machine is to use the
And as you can see, it brought the list of currently logged-in users.
Want to know more ways to list logged-in users? Here you have it.
How to find logged-in users in Ubuntu
Here, I will share some interesting utilities that will offer additional information such as the time of logging in, IP address, and a lot more.
So let's get started with my personal favorite.
Use the w command to find logged-in users in Ubuntu
The w command can show you the currently logged-in users and what they are doing.
All you need to do is enter
w in your terminal and it will bring the list of logged-in users:
TTYwill show the terminal used to log in. Here,
tty7indicates the user is logged in via the native terminal whereas the
ptsis used to indicate the ssh connection used to log in.
FROMcolumn will show the IP address of the remote connection.
[email protected]will show the time of logging in.
IDLEwill show how long the user has kept the system idle.
JPCUis the time used by all the processes that are attached to tty.
PCPUwill show the time taken by the current process that is shown in the
WHATsection sitting right in the corner.
WHATwill show the name of the current process.
And the above description will remain the same for all the utilities that I'm about to show you.
Use the who command to find logged-in users in Ubuntu
The who utility can show who is currently logged in to your system (pretty generic name right?).
While you can execute the
who without an additional option, I would recommend using the
-H option to have headings for each column:
LINE section will show the type of terminal used to log in (similar to TTY in the earlier command) and the
COMMENT column will show the IP address.
Use the finger utility to find logged-in users in Ubuntu
Want to have the most detailed output in terms of finding logged-in users? Use the finger utility.
Unlike the other utilities, it does not come pre-installed and you'd need to use the following command for installation:
sudo apt install finger
Now, all you need to do is execute the following:
And you'd notice that it has some extra columns showing details such as full name, phone, etc.
The reason behind the extra details is that finger is a user information lookup utility so if you added extra details while adding a user in Linux, those details will reflect here.
Bonus: List logged-in users since the last reboot
If you want to know who logged in to your system from the last reboot, you can use the last command:
The last command will simply look for the binary database located at
/var/log/wtmp to list users who logged in since the last time system was rebooted.
This was a quick article on how you can find the currently logged-in users in Ubuntu.
And if you are using any other utilities, let me know through the comments.