10

On Linux (Fedora 14), the "w" command says this:

[USERNAME@PC ~] w
 23:51:32 up 13 min,  7 users,  load average: 0,22, 0,42, 0,34
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
USERNAME        tty1     :0               23:39   12:49  30.71s  0.08s pam: gdm-password
USERNAME        pts/1    :0.0             23:39    9:39   0.01s  0.01s bash
USERNAME        pts/0    :0.0             23:51    0.00s  0.02s  0.00s w
[USERNAME@PC ~] 

Why are there 7 logged in users when it only lists 3?

LanceBaynes
  • 40,135
  • 97
  • 255
  • 351
  • Duh! I didn't even know about w, shame on me! – phunehehe Dec 27 '11 at 12:06
  • This also applies to Ubuntu. – Philip Dec 27 '11 at 12:36
  • Weird. Doesn't happen on RHEL 5.4 on a few boxes I looked at (including one rather busy and one completely idle server). – Mat Dec 27 '11 at 16:46
  • 1
    What does last|grep 'still logged in' say? – phemmer Dec 27 '11 at 19:09
  • 1
    Maybe you need to run it as root ? – Dom Dec 27 '11 at 19:54
  • w is in the procps package, there are several versions, make sure you have the latest. If you have the time you should download the source for procps and build it, iff you have the necessary build env and skills.

    I skimmed through w.c and saw a few comments about the 'likely' need for a switch to show more info about invalid processes. Regardless on arch, ubuntu, centos, and suse I was only able to reproduce your output on one machine, ubuntu I think. w is a mashup of who, uname, uptime. Other than plain old intellectual curiosity, do you have a task to complete?

    – bsd Dec 30 '11 at 17:33
  • what's your output from who does it match? what about output from users? – J. M. Becker Dec 31 '11 at 04:35
  • ..sorry, after rebooting the "w" shows good informations.. :\ – LanceBaynes Jan 04 '12 at 22:50

1 Answers1

1

This answer to User logged in by sftp does not show up in `w` suggests that w uses utmp logging - some digging shows that utmp is a file in /var/run/utmp.

If a program hasn't cleaned up utmp after logging to it, I suspect w may produce output like what you ran into.