Which iMac do you have?
You can find the best answer by going to About this Mac, then to System Report.
Under the Hardware Overview, look for your
Model Identifier. It will be something like iMac9,1
If your 2009 iMac is an iMac9,1 or earlier, then you will be limited to OS X 10.11.6 (El Capitan)
If it is a Late 2009 (iMac10,1 or higher), then you are limited to High Sierra (macOS 10.13.6).
The oldest Macs that are upgrade-compatible with Mojave are most 2012 Macs.
If you do have one that can upgrade to Mojave, and you are already upgraded to 10.8 or higher, you can do that easily from your App Store.
If you want the full installer app for either El Capitan, Sierra, or High Sierra, you can follow the links on
this page.
Scroll to the bottom, under Learn More, and follow the links to the App Store page for the version that you want.
You DO NOT need to install each version in sequence. You can go directly to High Sierra from Mavericks, if you want to do that.