I am logged into Ubuntu server via ssh and I would like to know if another user is logged in via SSH as well. Is there a command that I can run to accomplish this?

3 Answers 3


Just type who:

~$ who
(unknown) tty7         2013-12-06 13:37 (:0)
john      pts/0        2013-12-08 00:16 (
jane      pts/1        2013-12-08 00:17 (


Regarding your bonus question :)

To see login history for users you can use last -i. This will show all logins and IP addresses since start of current logfile /var/log/wtmp.

Depending on your logrotate you can show previous logs with last -f /var/log/wtmp.1, too.

To only show the very last login for each user use last -i | sort -r | uniq -w 16

~$ last -i | sort -r | uniq -w 20
wtmp begins Sun Dec  1 16:54:49 2013
john    pts/0    Sun Dec  8 18:49   still logged in   
jane    pts/1    Sun Dec  8 00:17 - 00:34  (00:16)
  • When I type it it doesn't give me the ip address. Is there a way to force the ip address? Commented Dec 7, 2013 at 23:36
  • You can use who --ips. I manually changed the output above to hide my internal network structure :)
    – Germar
    Commented Dec 7, 2013 at 23:39
  • Can I ask one more bonus question? Is there a way to get a list of ip addresses with the last time users have logged in from these ip addresses? Commented Dec 8, 2013 at 0:29
  • take a look at my edit
    – Germar
    Commented Dec 8, 2013 at 18:19

who is good, but simply w is better.

  • 2
    It would be nice if you explained the difference :-)
    – guntbert
    Commented Dec 8, 2013 at 19:16
  • It's a personal taste thing. But if I had to convince someone I would say that w is shorter than who but prints out more. So we get more for less. :) Or I would just quote from the manpages: who - show who is logged on but w - Show who is logged on and what they are doing. And it is obvious that we want to see what others are doing :D
    – falconer
    Commented Dec 8, 2013 at 23:11
  • 2
    Please edit your answer accordingly - I myself know what I am using :-))
    – guntbert
    Commented Dec 9, 2013 at 9:27
  • Why? For me the answer is good. Simple question simple answer.
    – falconer
    Commented Dec 9, 2013 at 9:47
  • 2
    Only answers are kept here - comments will vanish some time - so what you say in a comment will get lost eventually.
    – guntbert
    Commented Dec 9, 2013 at 16:15

and in realtime:

$ watch -n 1 w

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .