It all depends on how your users and groups are stored.
Legacy Unix/Linux systems use simple text files as user and group databases:
- /etc/passwd contains the user database
- /etc/shadow contains password hashes for the users in /etc/passwd
- /etc/group contains all groups
- /etc/gshadow contains group password hashes
If you just want to copy all user accounts and groups from one system to another, you can simply copy the files. This will of course overwrite the files on the destination system, and any locally defined users/groups will effectively be deleted. Also, the destination system will inherit all UIDs from the source system, which may not be what you want, especially if you're using different distributions (some common system accounts have distribution-specific UIDs).
Keeping user accounts in sync across systems is a really old problem in Unix, and there are several solutions:
- NIS (originally yp - Yellow Pages) and NIS+ (Solaris only, I believe) are a set of daemons that copy user and group accounts between systems
- Hesiod is a system that places account information and password hashes in DNS records (not recommended for security reasons)
- Kerberos uses a centralized user/password database
- various directory services can be used with LDAP authentication
If you want to keep accounts in sync across many systems, use a directory service. The Linux authentication subsystem can be configured to use LDAP via PAM modules. The most common products are OpenLDAP and Active Directory (yes, really). The latter does not require Windows servers if you use Samba.