Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • I know you said you don't want to use ps (hence a comment instead of an answer) but would something like ps -aux | tail -n+2 | cut -d' ' -f1 | sort -u work? Of course, that also includes system users running non-interactive processes, but we can work on that if you think this is a promising avenue to pursue. Commented Nov 2, 2020 at 16:26
  • List LDAP users on linux client? suggests you need to make some changes so that LDAP users are included in the output of getent. Commented Nov 2, 2020 at 17:23
  • It's an interesting question, but I can't help notice the collision between "users ... who have interactive processes currently running under their user IDs" and "without searching through the output of ps". Since ps is the tool to query active processes, could you clarify why ps is not allowed? Commented Nov 2, 2020 at 17:50
  • Your requirement of "not using ps" could be easily bypassed by getting the information directly from /proc (from the same place ps gets it) grep Uid: /proc/*/status, etc ;-) Keep in mind that a user id is simply a number, and any privileged process can just setuid(some_uid), without it having to go through pam/utmp, and without some_uid having to exist in any database, or have attached to it a name or a home directory. The only way to get a list of all active uids is to look through all the processes running on that machine. Commented Nov 2, 2020 at 22:31
  • Also, there's no way to know if a process is "interactive" -- which is a nebulous concept. Just like having "authenticated" via "normal" mechanisms. Commented Nov 2, 2020 at 22:34