1. Using the “who” command

We use the who command to get information on the different users connected with the information displayed in four columns.

The first column shows the usernames.The second column indicates the TTY used.The third column is the time the user logged in.The fourth is the hostname or IP address of the connected users.

You can also display the number of users logged on to the system with the -q parameter. It is possible to have more information by displaying all details of the current logged-in user with the -a option. You can get more details on how to use the command by using the –help command if you need additional information.

2. Using the “w” command

Contrary to the who command, the w command shows the users who are logged in and what they are doing. The output shows some useful information such as:

current timehow long the system has been runningnumber of users currently logged inname of the logged-in userremote hosttime the user logged in

You can also display just the information about the logged-in users when you use the -h option. You can filter the output of the command by using some other options. It’s possible to have a full list of the different options and their roles with the w –help command.

3. Using the “users” command

There is also the simple command users that shows only the users currently logged in without a parameter. That command doesn’t give additional information like the other commands, but you still have an idea about the users currently logged in to the system. When you use the man users command, you see that there is no other information.

4. Using the “last” command

There is another command that we can use. The last command with the -a parameter gives you some information, such as the username (even the special users like “reboot”), TTY, IP address from where the users are connected, and some others. When you use the -p parameter, it is possible to display the users connected to the present day. The command also offers more options that can help you to have useful information. You can check with the man last command. With all the commands above, you can easily list the logged-in users on Linux. This will allow you to monitor your system and see if there is any unauthorized access. You can take some actions with the identified users, if needed, with these users management commands. Image credit: Panda for helping little skaters to teach skate on ice by Yayimages