Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given a machine name, I want to check if someone's logged in on that machine or not. Just a yes/no answer would be sufficient (I don't want their username). Any hints on what command to look for?

By 'logged in' - I mean using a graphical UI on that machine - ssh doesn't count.

You can assume that I have an authorized ssh login for this machine.

share|improve this question
up vote 10 down vote accepted

who shows you who is logged in. If they are in a gui, their "terminal" is the X display they are attached to (otherwise the tty):

paul     :0           2013-02-20 11:43


who | grep paul

would return nothing if I wasn't logged in, or something if I was.

If you wanted to exclude ssh and console connections, then:

who | grep -v pts | grep paul

You can run this command remotely by adding to the ssh command:

ssh user@host 'who | grep -v pts | grep paul'

This will log into the remote machine, do the who, and return the results.

share|improve this answer
That looks good! I'm assuming you need to ssh into the machine first - and then run 'who' - is that correct? Or can I use 'who' (or some other incarnation of it) locally and check the status on remote machines? – Utkarsh Sinha Feb 28 '13 at 6:18
@UtkarshSinha I have added a bit at the end to run it remotely. This kind of thing works best if using public keys instead of passwords for ssh, so you don't need to enter a password. – Paul Feb 28 '13 at 8:22
That's perfect. Thank you! – Utkarsh Sinha Feb 28 '13 at 15:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.