This answer isn't particularly Ubuntu, but it's often the most convenient one.

Find out the model of your computer (or if it's a custom assembly job, of your motherboard). Enter the model in the memory search tool on the website of a major RAM vendor (for example Crucial or Kingston). The site will tell you which of their product are guaranteed to be compatible with your system. Even if you don't wish to buy from that vendor, you can note the characteristics and look them up on your favorite vendor.