Cavaignac entered the École Polytechnique in 1820, then left two years to continue his studies in Metz. Having finished his military education he joined the army as a sub-lieutenant of the 2nd regiment of military engineers. Promoted to Lieutenant in 1826, he served between 1828 and 1829 in the Morea expedition, the French intervention in the Greek War of Independence. He was stationed in Arras when the July Revolution broke out, and became one of the first officers to join the revolt against the Bourbon monarchy, and was soon promoted to Captain in October 1830, under the new July Monarchy.