In 1811, Luís Alves moved with his parents from his grandparents' farm to Rio de Janeiro and was enrolled at the "Seminário São Joaquim" (Saint Joachim School), which became Pedro II School in 1837. On 4 May 1818, he was admitted into the Royal Military Academy. The entire course (which ran from the first to seventh year) was mandatory for artillerymen and engineers but infantrymen were only required to take first- and fifth-year classes. Luís Alves took the first- and fifth-year classes in 1818 and 1819, respectively. Though he could have skipped the other years, he chose to take second-year classes in 1820 and third-year classes in 1821. The subjects he studied in the Royal Military Academy ranged from arithmetic, algebra and geometry to tactics, strategy, camping, fortification in campaign and terrain reconnaissance. He was promoted to "alferes" (equivalent to a modern-day second lieutenant) on 12 October 1818, and to lieutenant (modern-day first lieutenant) on 4 November 1820.