Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Can anyone explain me why w shows me a wrong number of users currently logged in?

root@host ~
# w
 20:14:54 up 17:13,  3 users,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    xx.xx.42.51    19:29    0.00s  0.50s  0.00s w
flint    pts/2    xx.xx.42.51    19:53    3:32   0.43s  0.00s tmux a

root@host ~
# who
root     pts/0        Aug 14 19:29 (xx.xx.42.51)
flint    pts/2        Aug 14 19:53 (xx.xx.42.51)

root@host ~
# users
flint root
share|improve this question

1 Answer 1

up vote 2 down vote accepted

/var/run/utmp can sometimes get corrupt and incorrectly report the number of users that are logged.

If you do a sudo tee /var/run/utmp < /dev/null it will get reset. It is not needed to be single-user but it is advisable: logged in users might see some weird results when they try to view users until they log out.

Sources linuxquestions.org and Redhat mailing list.

share|improve this answer
2  
Use last to get an idea where it went wrong. Example line: ubuntu pts/21 :0 Sat Aug 6 23:12 gone - no logout –  Lekensteyn Aug 15 '11 at 8:23
    
@Rinzwind Thanks a lot! Resetting the file fixed the problem :) –  Flint Aug 16 '11 at 2:08
    
@Lekensteyn You're right. I saw few lines that say 'crashed' etc. –  Flint Aug 16 '11 at 2:08

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.