Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having a little problem. I need to (from the command line) be able to see what users are logged in.

Here's the tricky part: I DO NOT want those users that have locked their screens and left their desktop to show up in my list.

I've tried doing these two things, but both of them show users that have locked desktops. Is there anything else I can do?

    w

    last | head -n 1
share|improve this question
2  
How is the program supposed to know when the user has locked screen? You don't even mention if they are using GNOME, KDE, or a custom environment; whether they have GNOME Screensaver, Xscreensaver, slock, or such. –  grawity Mar 11 '12 at 17:30
    
They're using GNOME with GNOME Screensaver –  davorb Mar 11 '12 at 18:24

1 Answer 1

who -Hu

will provide you a list of logged in users, and their idle times.

who -u

will forego printing the headers. To know whether it will report correctly for screen-locked users, I guess you'll have to test it. Here's the output from my system right now:

[mini-nevie:~] nevinwilliams% /usr/bin/who -Hu
USER          LINE     WHEN         IDLE       PID  COMMENT
nevinwilliams console  Apr 18 01:27  old        62
nevinwilliams ttys000  Apr 20 14:34 00:08    31675
nevinwilliams ttys001  Apr 20 14:35 00:04    31695
nevinwilliams ttys002  Apr 20 14:42   .      31758
[mini-nevie:~] nevinwilliams%

I ran the command from ttys002.

share|improve this answer
    
Using grep, you could then only show results that show results with an idle time less then that of your screen saver timeout period. That would, at the very least exclude all users who were timed out. What it wouldn't necessarily show would be those users who lock when they leave their workstation. –  Usta Apr 20 '13 at 18:25

Your Answer

 
discard

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.