Alternatively, you can just copy the iTunes folder under Users\[your name goes here]\Music over to the other iMac... That's your whole iTunes library... complete with all apps, books, movies, and anything else. One caveat is that it doesn't carry iTunes settings like EQ and preferences over.
Also both Macs have to have the same iTunes version.
Using that method, you can sync your iOS device to as many computers as you have registered under your account, and keep the same contents throughout. Max is 5, obviously.