Introduction You can use the following commands for user monitoring on Linux operating systems including to see a list of current logged in users on Linux:
- w command : Show who is logged on and what they are doing on Linux
- who command : Display information about Linux users who are currently logged in
- whoami command : Find out who you are currently logged in as on Linux
- id command : See user and group information for the specified USER account on Linux
All user names are stored in /etc/passwd file and can be displayed with help of cat command or grep command/egrep command:
cat /etc/passwd
grep '^userNameHere' /etc/passwd
grep '^tom' /etc/passwd
Let us see all examples and usage in details.
How to show current logged in users in Linux
Open the terminal window and type:
w
The w command shows information about the Linux users currently on the server, and their running processes. The first line displays, in this order:
- The current time ( 22:11:17 )
- How long the Linux server has been running (18 days)
- How many users are currently logged on Linux (2 users)
- The system load averages for the past 1, 5, and 15 minutes (1.01, 1.04, 1.05)
The following info displayed for each current logged in user:
sweta pts/10 minitx 22:11 5.00s 0.04s 0.02s vim replicant.py
Where,
- sweta – Login name
- pts/10 – The tty name
- minitx – The remote host/desktop/laptop name
- 22:11 – Login time
- 5.00s – Idle time
- 0.04s – JCPU (it the time used by all processes attached to the tty. It does not include past background jobs, but does include currently running background jobs.)
- 0.02s – PCPU (it is the time used by the current process, named in the “what” field.)
- vim replicant.py – The command line of their current process
Find out who you are currently logged in as on Linux
Execute the following command:
whoami
Another option is to just type the following id command:
id
Linux show who is logged on
Again run the who command:
who
OR
who -a
Conclusion
This page showed how to find out current logged in users in Linux and what they are doing from the terminal. For more info see man pages using the man command:
man w
man who
man whoami
Yes, I used all three to get what I needed from my SUSE server :)
id command wasn’t that useful tho.