I'm looking for a simple way to determine the number of currently logged in users, using only the filesystem and basic bash functions (instead of using binaries).
uptime binary appears to be reading from
/var/run/utmp according the its source code, but
/var/run/utmp doesn't seem to update in real time (it shows
pts/1-5 for my user, but I'm only on
pts/5 at the moment). However, the
uptime binary correctly shows "2 users".
Note: Instead of relying on
getutent() in C, I'm trying to better understand how the underlying system works.
What's the best place to find a current, accurate number of users logged into the system?