On your personal computer at home, you are most likely the only user who is connected to your Linux system. However, if you are a user at the Linux server in your company there can be other users as well.
In this case, it is good practice to know the information about other users who are currently connected to the same Linux machine using several commands.
How to Check Currently Logged in Users in Linux
To begin, use the users’ command – which shows a list of all users currently connected to the Linux system with no further details:
# users
If you want to know more information about the currently logged-in users, you need to use the who command as explained in the next section.
How to Get Information of Currently Logged in Users in Linux
The who command not only prints the users who are currently connected to the system, but also the IP address from where they are logged in and at what time.
# who
The reality that who command prints the IP address of remote users is extremely helpful. If, for example, a user is misbehaving then the system administrator knows from which IP address that user is connected, and this makes it easier to take corrective actions and lock the user permanently from the system.
How to Check Users Activity in Linux
If you want to know what a user is doing on the system, you need to use the w command – which shows you the names of users, from where they are logged in, and at what time, ongoing usage statistics, and what commands or programs they currently are running.
$ w
If you want to know more information about other users, try using the finger command as explained.
Find More Information of Users in Linux
The finger command shows a summary of the current state of a local user account that includes user recent activity, unread mail messages, and home directory. In most of the Linux distributions, the finger command isn’t installed by default.
$ sudo apt-get install finger [On Debian/Ubuntu & Mint] $ sudo dnf install finger [On RHEL/Fedora/CentOS/Rocky Linux and AlmaLinux]
Once installed, you can run the finger command followed by the username as shown.
# finger linuxshelltips
In this short article, I’ve shown several commands to get the user information in Linux. If you know any other command to get the user details, do share with us in the comments.
“If you are a user at the Linux server in your company”
Mere users do not get access to login shells on corporate servers.