UNIX / Linux list current logged in users

by Vivek Gite on October 2, 2007 · 5 comments

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:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 5 comments… read them below or add one }

1 confy March 19, 2008

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:~$

Reply

2 هادی January 24, 2012

tnx a lot

Reply

3 4F2E4A2E October 14, 2009

the awesome w :)

Reply

4 Ant May 27, 2011

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.

Reply

5 dikshitha November 18, 2011

we are using linux through putty.
I want to get an alert when user logged in.how can we write code for that?

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 4 + 13 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: