1

I use Gnome 3 and I have 2 desktops on it (2 users). Both of them are logged simultaneously and I navigate between desktops via Switch User option.

Sometimes, my other desktop won't load and I kill that user via pkill -KILL -u username command.

Now, I have more users but when I try who the console does not display other user. How can I see which users are logged into Gnome3 in the same time?

3 Answers 3

3

Try:ck-history --last

This will include users who logged in via Gnome / GDM. I found that commands like 'who', 'w', 'finger', 'last' only display terminal logins.

1
  • this actually works. Thanks. But the better command is ck-history --last | more as there are MANY data in it :)
    – ubuntico
    May 12, 2012 at 14:41
2

You can try the following command:

sudo who -u -d

This should show you all logged in users - even the ones with dead processes.

1
  • I noticed that only the sudo user shows up in the who command. Even if I login as the other user and type who, only the sudo user appears.
    – ubuntico
    Jan 22, 2012 at 17:30
0

A logged in user will be running a process gnome-session-ctl. Assuming that keeps running when you switch user, so you can look for that and get its owner:

pgrep gnome-session-c | xargs ps u | awk '/gnome-session-ctl/{print $1}' | grep -v gdm

Note:

  • Linux stores only 15 chars of the process executable name directly with the process, hence pgrep can only look for gnome-session-c. Anything longer needs a lookup; ps gives us that lookup - and the user name.
  • gnome-session-ctl can appear as an argument to another process, so casually grepping ps for gnome-session-ctl without additional filtering may get false positives.
  • Excluding the gdm user is a safety net just in case gdm ever starts a ctl process - you probably don't want to kill gdm! Maybe overkill but better safe than sorry.
  • Note that you could also go after some other gnome process such as gdm-x-session or gdm-session-worker.

You must log in to answer this question.

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