Excellent answer @HWTech !
either mid-2007 or early-2008 iMac runs fine nowadays El Capitan with better usage than Ubuntu.
The OP can {considering just to be sure about the serial] install ElCapitan on it using any external USB portable HD, without erasing the internally installed Ubuntu.. than just remove the USB HD after getting the Serial Number
Or go further and enjoy a good experience using El Capitan on that iMac
I have one iMac early 2008 here by my side which is perfect for Internet, Microsoft Excel, e-mails, having iTunes synced with my Apple Music account, and plays perfectly youtube videos at 1080p... with 4GB RAM
There was still a recent security update for it from Apple recently (on Jan/2020) and Apple keeps updating El Capitan with the latest MRT (Malware Removal Tool) version and Sys Policies synced/aligned exactly at the same Mojave and Catalina security packages.
You don't have Music App, nor any modern app. But it has a secure updated system, has an updated Safari, and everything else for daily usage. It does not have: Siri, Dark Interface and Airdrop.. but full iCloud sync and everything else is being updated. On El Capitan, with 4GB RAM, it runs fine Parallels 13 with Windows7 VM, really fine.
I lost the focus of the question... Sorry... Lol
I agree with you:
install El Capitan on any external USB HardDisk, get the Serial on "About this Mac".. takes 40min of your life, and problem solved.
:)