Who is logged in to multiuser XFCE4 server

It was driving me up a tree for a long time. We have a virtual XFCE4 machine designed for our technicians to log into. However, there did not seem to be any clear way to find out who was actually logged in ('w' only shows command line logins)

Finally, after searching for a while, I found that you can figure it out with the lsof command; they have a "file" opened for their xfce session.

The following script shows who is logged in via xfce4.

#! /usr/bin/perl -w

# http://www.cyberciti.biz/tips/linux-display-open-ports-owner.html

@list = ´lsof -i | grep xfce4-ses´;
print "Users Logged in\n";
for ( $i = 0;$i < @list; $i++ ) {
   my ( $COMMAND,$PID,$USER,$FD,$TYPE,$DEVICE,$SIZE,$NODE,$NAME ) = split ( " +", $list[$i] );
   print "$USER\n";
Last update:
2015-03-06 00:48
Average rating:0 (0 Votes)

You can comment this FAQ

Chuck Norris has counted to infinity. Twice.

Records in this category