Listing out groups of users
You can get a list of all your local users with this command:
$ getent passwd | awk -F: '{print $1}'
A list of who's currently logged in:
$ who
A list of user's that are currently not loggd in:
$ grep -vfFxvf <(who | awk '{print $1}' | sort -u) \
<(getent passwd | awk -F: '{print $1}')
This last one takes the list of users who are logged in and shows the list of all user's minus the logged in users, using grep -vf.
Getting counts
To get counts, simply take a wc -l on to the end of commands.
not logged in
$ grep -vfFxvf <(who | awk '{print $1}' | sort -u) \
<(getent passwd | awk -F: '{print $1}') | wc -l
53
logged in
$ who | awk '{print $1}' | sort -u | wc -l
1
grep flags
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by newlines,
any of which is to be matched.
-x, --line-regexp
Select only those matches that exactly match the whole line.
-v, --invert-match
Invert the sense of matching, to select non-matching lines.
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file contains
zero patterns, and therefore matches nothing.