The Cinque Terre are gorgeous. What port are you seeing them from?
If it's La Spezia, don't waste your money on the ship's excursion. You can take a boat from close to the tender dock to the northernmost town, Monterosso, and work your way back from there. Or you can walk to the train station, which is what we did. Tickets are cheap - I think we paid less than 3 Euros each, and they were good for 6 hours' worth of riding - and you can hop on and off depending on which trails you want to hike.
I haven't visited the CT from Livorno, but that would probably be easy, too, via train.
Do get the Rick Steves book - he will tell you something about each town, and make it simple to do it on your own.
And do try the pesto - DH doesn't even like pesto and raved about it. The CT claim to have invented it.