how many user accounts can a unix-like OS host? [duplicate]

Solution 1:

Theoretically you can have as many users as the user ID space supports. To determine this on a particular system check out the definition of the uid_t type. It is usually defined as unsigned int or int meaning that on 32-bit platforms you can create up to almost 4.3 billion users. On 64-bit platforms you can have more than 16e18 different user IDs.

However, other resources may become exhausted before you reach this limit, e.g. disk space. If you create a home directory for each user then even with just 1MB of space for each user you need over 4PBs of storage. Also, large number of users leaving processes running in the background, scheduling cron jobs, opening ftp and/or ssh sessions can create a severe burden on the system.

Solution 2:

Up until the UID space is exhausted. Contemporary systems use 32-bit unsigned integers, with 65535 and 4294967295 being magic values for "any"/"unknown"/etc., so there is room for 4294967294 concurrent distinct users. Older systems may still show 16-bit unsigned integers.

Solution 3:

Other answers have responded literally to OP's question regarding specific limits. Given the nature of SF as a long-term reference too, I think it's important to point out a very important caveat on the approach you're contemplating.

You want to be using a directory service to manage user accounts on this scale. It's exactly the problem that directory services [e.g. OpenLDAP, Active Directory, et al.] were designed for.

Using "standard"[1] Unix user tools to manage more than a handful of local user accounts is a well-worn pathway fraught with pain, will not scale very easily and - given your problem description - will in all likelihood lead to a significant re-architecting of your chosen solution when it does not in fact scale horizontally with multiple servers.

[1] They generally work very similarly, but the exact incantations vary from platform to platform, are different sometimes even in similar heritage Linux distros and of course are regularly changed with OS release versions. Caveat emptor.