Welcome!
As iMacs have been in continuous production since 1998 in four broad families and hundreds of variants, it is hard to answer this without the context of sub-model model information.
The serial number is the first step. Look on the outside of the case for the serial number. If the iMac has a metal "foot" that supports it, the serial number is on the bottom of that foot.
On older models the number can be screened onto the case or on a sticker, possible requiring you turn the computer upside down to find.
Once you find a serial number, go to this Apple support page and enter the serial number:
Check Your Service and Support Coverage - Apple Support
Although you do not likely have support coverage, the info return should report the important sub-model:
We need is the bit in parentheses; in the example image, "27-inch Mid 2010"
The Apple lookup may not work for very old Macs. In that case, you can use this third-party lookup function:
https://everymac.com/ultimate-mac-lookup/
Our knowing the iMac sub-model is key to your getting useful, problem-specific advice here. Without out it we either give overly-broad information or, worse, bad information. Neither makes you quest easier.
Even with a proper model designator, if the original owner did not properly follow the steps in this article before selling it on, you may never have full use of the computer:
What to do before you sell, give away, or trade in your Mac - Apple Support
Allan