Obviously some titles like general are old as dirt but what about the ranks used by the US army or marines? Where do terms like liuetenant, corporal, private, major, and sergeant come from? Moreover how do rankings evolve over time? For instance I know he British use the rank leftenant in their armed forces but the US doesn't, where do all of these rankings come from?
I don't know much about how the various ranks settled into their modern places, but I can tell you about the origins of the terms.
The lieutenant is from Old French lieu + tenir "to hold a place," which is itself probably from a Latin phrase locum tenens "the one holding the place (for another)." The idea is of an understudy, or 2nd in command. British English "leftenant" is an alternate pronunciation which has obscure, probably early Medieval origins. Spellings in Middle English show that there were already variant pronunciations.
Captain is straightforward. Latin caput "head" to vulgate capitaneus "important, chief" to Old French capitaine "leader." Cf Middle English capitayn, which I swore was in the Knight's Tale but I can't find it now after 30 seconds of looking.
Major is also easy. It is French again, short for sargent-major, and from Latin adjective maior "older, greater."
Colonel is more weird. Ultimately it is from one of the Latin words for a column (like in architecture), columna. Its military sense is Medieval Italian, meaning "at the head of a column of troops," and related to the Italian compagna colonella (which is a descendant of that original Latin word). I'm not sure how English wound up with the pronunciation involving an R, but French and Spanish both have coronel.
Brigadier is simple, from the same French word meaning "one in charge of a brigade." Brigade is via Italian brigare "to fight" from briga, probably Celtic in origin.
General is a modern shortened form of French capitaine général -- in other words, just the adjective of that phrase. The "general" part of the title indicated the captain's increased areas of responsibility.
Corporal derives either from Latin caput "head" or Latin corps, corpis "body." In medieval Italian, caporale, which seems to be a blend of the two. A caporale was in charge of a "body" of troops. Our word is probably via Old French corporal.
Sergeant is, again, from Latin. The -nt is characteristic of a Latin present active participle, in this case from servire, "to serve or be a servant." It's military use is, again, French, from the 13th-14th century AD.
For Ensign, I'm not very sure. It is again from Latin īnsīgne, or badge of rank.
Admiral - I saved the best for last. I actually had no idea about the origin of this term until now. I had always assumed it was from the Latin adjective admirabilis "admirable, wondrous" but that is not the case. Admiral is from medieval Arabic amir "military commander." The intrusive -d- might be from analogy with Latin admirabilis though. The term was originally applied to Saracen ground commanders, but began a shift to naval terminology from the 12th century onwards.