3

Running Ubuntu 12.04. I have many users logged in via SSH and opening an Openbox session. How do I loop through all the logged in users and their display number so that I can execute a command for specific users?

The command would be the extension of restarting a Java application that they have open.

I have tried who -a, but it doesn't seem to list any SSH users and their display number. I am able to get display numbers via cd /tmp/.X11-unix but not their corresponding user login.

Giacomo1968
  • 58,727
john
  • 43

1 Answers1

2

Try who or who -a. it displays the user name, TTY/PTS (with id), and the display number (if local) or remote location. See here for the manpages.

This is one local session and two SSH sessions:

:~$ who
myuser tty7         2015-09-10 00:44 (:0)
myuser pts/2        2015-09-13 19:32 (MyWorkstation.net)
myuser pts/4        2015-09-13 19:34 (MyWorkstation.net)
Frank Thomas
  • 37,476