There was a temporary network glitch and all user terminal ssh sessions were broken. Upon logging in to the CentOS server again and running the "w" command lists a higher number of users logged in than they actually. It adds up the users whose session was broken. Manually killed the earlier "pts" sessions. However the number of logged in users is still higher than the actual number now.

Is there any way I can properly kill these disconnected "ssh" sessions to get correct number of logged in users in "w" output?

  • This could help, at least it sounds like the same problem that you have.
    – user37607
    Commented Nov 28, 2013 at 10:33

3 Answers 3


This could be due to corrupted /var/run/utmp file, and if that's the case, it can be repaired with the following command, which is preferred to run in single-user mode, otherwise users who are currently logged in may experience some weird behaviour:

# >/var/run/utmp

That command will clear the contents of file /var/run/utmp, and the # states for root prompt. After that you could reboot your system.

Source: Why does the “w” command report a wrong number of logged in users?

  • 1
    Note the command he's showing there is >/var/run/utmp which will zero out the file, the # is his prompt, which is showing you that you need to be root, or have elevated credentials to do this command.
    – slm
    Commented Nov 28, 2013 at 18:09
  • @slm Thanks for noticing, I'll add that to my answer.
    – user37607
    Commented Nov 28, 2013 at 18:42

This might be caused by a corrupted utmp or utmpx file.


There is really no way for the server to know the difference between a session that was cut off due to a network outage and a session where the user got up and walked away.

Some shells may have a timeout feature where, if the shell does not see any activity for a specified amount of time, it will disconnect the session.

You must log in to answer this question.

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