Q. How do I print the user names of users currently logged in to the current UNIX / Linux host / server from a command prompt?
A. You need to use users command. It displays the login names of the users currently on the ystem, in sorted order, space separated, on a single line. It reads all information from /var/run/utmp file.
users command
Just open terminal or login over ssh session and enter the following command:
$ users
Output:
abhi charvi vivek vivek zcafe
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -


{ 5 comments… read them below or add one }
but why not using “w”??
confy@live:~$ w
00:35:35 up 13 days, 1:35, 2 users, load average: 0.27, 0.34, 0.58
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
confy tty7 :0 06Mar08 0.00s 3:06 1.59s x-session-manager
confy pts/0 :0.0 00:33 0.00s 0.09s 0.00s w
confy@live:~$
tnx a lot
the awesome w :)
I have a .txt file with denied users listed on it. Is there any way I can run a loop to regularly compare the ‘who’ or ‘users’ output with the list to see if denied users are logging on? I do not want to block the users completely. I am new to unix, any help would be much appreciated.
we are using linux through putty.
I want to get an alert when user logged in.how can we write code for that?