2nd hand iMac with no OS
I have a 2007 iMac. A while back, I replaced the internal drive with a 1 TB hard disk. The Mac still has a working optical drive. Currently, the mac has 64 bit Windows 10 Pro, Ubuntu Linux, Yosemite and El Capitan installed. I am fortunate, in that I have a 2011 iMac running High Sierra and a Snow Leopard DVD.

One path to reinstall would be to install Snow Leopard from a DVD. Apple still sells the DVD for 20 USD. If necessary, you should upgrade to OS X 10.6.8. One way to accomplish this would be to download the Mac OS X 10.6.8 Update Combo v1.1. Finally, the current instructions for upgrading to El Capitan can be found here. This site has a this link to the Apps Store where El Capitan can be downloaded.

Another path would be find someone who has purchased (for free) El Capitan. If this person has access to a Mac running High Sierra or earlier, then they can download El Capitan to this Mac. El Capitan can be transferred to a bootable USB flash drive installer. The instruction are given here. Basically, the command below needs to be executed on a flash drive formatted Mac OS Extended (Journaled) with the label (Name) MyVolume.

sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app



  Note: I also have a 2013 iMac running Mojave. When accessing the Apps Store, the Yosemite and El Capitan operating systems do not appear. So accessing previous purchases now depend on the version of macOS your are using.


Update: How to Get and Verify a Snow Leopard ISO File from the Internet

Mac User posted in an answer which states a Snow Leopard ISO file can be download from this website. This site shows an image of a DVD. I happen to have that very DVD. This is OS X version 10.6. So I decided to conduct some research using an iMac (21.5-inch, Mid 2011) running macOS High Sierra Version 10.13.6. Here is the work and results.

First, I downloaded the ISO file from the website. This was named snow leopard install.iso.

Next, I used the Disk Utility to create a DVD/CD master image of the Snow Leopard DVD named SnowLeopardDVD.cdr. I used the command shasum -a 256 snow\ leopard\ install.iso to get a SHA256 checksum, as shown below.

cbeeb2378c40b20a9b06236f567de593e9030a0a865515b50cf6d35833e25cd5  snow leopard install.iso


The command ls -l SnowLeopardDVD.cdr snow\ leopard\ install.iso produced the following output.

-rw-r--r--@ 1 davidanderson  staff  7771496448 Mar 19 01:11 SnowLeopardDVD.cdr
-rw-r--r--@ 1 davidanderson  staff  7771521024 Mar 18 18:34 snow leopard install.iso


This shows the download to be 24576 bytes larger. I used the hexdump -C -s 7771496448 snow\ leopard\ install.iso to display these extra bytes. The output shown below. This output shows all these extra bytes are zero.

1cf37a000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
1cf380000


Next, I used the Finder application to mount both files. The snow leopard install.iso file mounted as disk1 and the SnowLeopardDVD.cdr file mounted as disk3. Neither of the next two commands produced any output. This means the disk1 and disk3 are identical to the files that were mounted.


  Note: In some instances, I needed to unmount one or more volumes before using certain commands.


cmp /dev/disk1 snow\ leopard\ install.iso
cmp /dev/disk3 SnowLeopardDVD.cdr


The output from diskutil list disk1 and diskutil list disk3 is shown below. The output shows the partitions are the same type and size.

/dev/disk1 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        +7.8 GB     disk1
   1:        Apple_partition_map                         30.7 KB    disk1s1
   2:         Apple_Driver_ATAPI                         1.0 GB     disk1s2
   3:                  Apple_HFS Mac OS X Install DVD    6.7 GB     disk1s3

/dev/disk3 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        +7.8 GB     disk3
   1:        Apple_partition_map                         30.7 KB    disk3s1
   2:         Apple_Driver_ATAPI                         1.0 GB     disk3s2
   3:                  Apple_HFS Mac OS X Install DVD    6.7 GB     disk3s3


None of the commands shown below produced any output. This means the partitions are identical. 

cmp /dev/disk1s1 /dev/disk3s1
cmp /dev/disk1s2 /dev/disk3s2
cmp /dev/disk1s3 /dev/disk3s3


Next, I execute the command cmp -l SnowLeopardDVD.cdr snow\ leopard\ install.iso. Only the first and last 2 lines of the output is shown below.

1034487809 343   0
1034489856  65   0
cmp: EOF on SnowLeopardDVD.cdr


Since I now know both files are using the Apple_partition_scheme, I can post the output from the commands pdisk -lr /dev/disk1 and pdisk -lr /dev/disk3, as shown below. Again the partitions appear to be the same type and size.

Partition map (with 2048 byte blocks) on '/dev/disk1'
 #:                type name       length   base    ( size )
 1: Apple_partition_map Apple          15 @ 1      
 2:  Apple_Driver_ATAPI Macintosh  505105 @ 16      (986.5M)
 3:           Apple_HFS Mac_OS_X  3289554 @ 505122  (  6.3G)
 4:          Apple_Free                 3 @ 3794676

Device block size=2048, Number of Blocks=3794679 (7.2G)
DeviceType=0x0, DeviceId=0x0

Partition map (with 2048 byte blocks) on '/dev/disk3'
 #:                type name       length   base    ( size )
 1: Apple_partition_map Apple          15 @ 1      
 2:  Apple_Driver_ATAPI Macintosh  505105 @ 16      (986.5M)
 3:           Apple_HFS Mac_OS_X  3289554 @ 505122  (  6.3G)
 4:          Apple_Free                 3 @ 3794676

Device block size=2048, Number of Blocks=3794679 (7.2G)
DeviceType=0x0, DeviceId=0x0


Since I now know the block size is 2048 bytes, I can convert the byte counts given as output from the last cmp command to blocks, as shown below.

1034487809 bytes = 505,121 blocks * 2048 bytes/block + 1 byte
1034489856 bytes = 505,122 blocks * 2048 bytes/block + 0 bytes


The above conversion shows all the differences occur in the one unused 2048 byte block between the Apple_Driver_ATAPI and Apple_HFS partitions.

The next commands extend the SnowLeopardDVD.cdr file by 24576 bytes of zeros. The following command zeros the 2048 byte block between the Apple_Driver_ATAPI and Apple_HFS partitions in then SnowLeopardDVD.cdr file. 

dd if=/dev/zero bs=1 count=24576 seek=7771496448 of=SnowLeopardDVD.cdr
dd if=/dev/zero bs=2048 count=1 seek=505121 conv=notrunc of=SnowLeopardDVD.cdr


The command given below produces no output, thus confirming the SnowLeopardDVD.cdr and snow leopard install.iso files are now the same.

cmp SnowLeopardDVD.cdr snow\ leopard\ install.iso


The result of this research is outlined below.


The ISO I download is authentic. The differences that occur outside the partitions are not used and are zero in the ISO file.
If another website promotes the download of an ISO file of this same DVD, you can use the information in this answer to verify if the download is authentic. This is why I included the SHA256 checksum of the ISO file I downloaded.