Terrestrial Planet Atmospheres
Primary Atmospheres:
The primary atmosphere for every terrestrial world was composed mostly of light gases that accreted during initial formation.  These gases are similar to the primordial mixture of gases found in the Sun and Jupiter .  That is 94.2% H, 5.7% He and everything else less that 0.1%.
However, this primary atmosphere was lost on the terrestrial planets. Why? a combination of surface temperature, mass of the atoms and escape velocity of the planet.
What determines if a particular atom is retained by a planet's gravitational field? if the atom is moving less than the escape velocity for the planet, it stays.  If it moves faster than escape velocity, it escapes into outer space.
From the kinetic theory of gases, we know that the mean velocity of a bunch of atoms is set by the temperature of the planet's surface. Remember our microscopic description of macroscopic quantities such as pressure and temperature.  Higher temperatures translate into higher velocities for the atoms.
Now consider of mix of elements in an atmosphere.  Some atoms/molecules are low in mass (H, He) some are heavy (CO2, H2O, etc).  The light elements are moving faster than the heavy elements and can reach escape velocity.
The second variable is the surface temperature of the planet. The inner worlds are closer to the Sun, therefore warmer.  The opposite is true of the outer planets, farther from the Sun therefore cooler.
Combining the variables of escape velocity (mass, radius of planet) and surface temperature (distance from Sun plus effects of atmosphere heating) produces the following diagram.  For key elements, lines are draw to show where the element escapes from the planet.  If a planet is below that line, that element will escape.
So note that for the outer Jovian worlds, all the primary, initial atmosphere is held.  But for the inner worlds, most of the original H and He has been lost.  These inner worlds then will form a secondary atmosphere composed of the outgassing from tectonic activity.
Secondary Atmospheres:
For the warmer terrestrial worlds, the light, gaseous elements (H, He) are lost.  The remaining elements are grouped into the rocky materials (iron, olivine, pyroxene) and the icy materials (H2O, CO2, CH4, NH3, SO2). The icy materials are more common in the outer Solar System, they are delivered to the inner Solar System in the form of comets (see later lecture).
The rocky and icy materials mix in the early crust and mantle. If the planet cools quickly, there is little to no tectonic activity and the icy materials are trapped in the mantle (see for example the Galilean moons).  If the planet has a large mass (which means lots of trapped heat from formation), then there is a large amount of tectonic activity -> volcanos.
The icy materials are turned to gases in the warm mantle and returned to the planet surface in the form of outgassing to produce a secondary atmosphere .  The atmospheres of Venus, Earth and Mars are secondary atmospheres.
The composition of outgassing is similar for Venus, Earth and Mars and is composed of 58% H2O, 23% CO2, 13% SO2, 5% N2 and traces of noble gases (Ne, Ar, Kr).  The latter evolution of this outgassing is driven primarily by the surface temperature and chemistry of the planet.
Note that H2O is the key catalyst for the evolution of a secondary atmosphere.  On the Earth, the temperature was just right for the formation of liquid water = oceans.  The CO2 released by outgassing was dissolved in the liquid water to produce carbonate rocks.  Thus, the Earth had a reducing atmosphere.
On both Venus there was no liquid water (too hot) and, therefore, no place for the CO2 to dissolve.  If the atmosphere is reducing in CO2 than lower ranking elements become important once the CO2 is gone.  For the Earth, this meant that the atmosphere became primarily N2 based, with later additions of O2 from lifeforms.  On Venus, CO2 was not reduced and stayed as the primary component to their atmospheres.
On Mars there was a period of liquid water very soon after formation.  But there was insufficient temperature for this water to remain as a liquid, so it froze out leaving CO2 as the primary component in the atmosphere.
Also note how the noble gases are good traces of the amount of evolution an atmosphere undergoes. Noble gases do not react with other elements (they are inert).  An atmosphere that is thin and undergoes sharp changes in mass has a high percentage of noble gases.  In this case, Mars has had most of its atmosphere frozen out in the form of H2O and CO2 ice, leaving a high amount of noble gases.  Thick atmospheres, such as Venus, have small percentages of noble gases since most of the outgassing material remains on the planet surface.
Earth's Oxygen:
Note that most of the O2 released by outgassing is locked up in liquid H2O.  Since O2 is highly reactive, it must constantly be replenished.  Some is released by photodisintegration with H2O vapor in the upper atmosphere.
But most of the O2 in today's atmosphere is from the photosynthesis process associated with lifeforms.  This occurred about 1 billion years after the Earth formed.  The original secondary atmosphere of the Earth was lacking large amounts of O2 and was rich in N2 and CO2.
Greenhouse changes:
The greenhouse effect is controlled by the amount (by mass) of greenhouse gases in an atmosphere.  These gases are primarily H2O, CO2, CH4, NH3.  For secondary atmospheres on Venus, Earth and Mars, only CO2 has a major contribution to the greenhouse effect (although note that the amount of CH4 is increasing on the Earth due to the waste products of animals and agriculture).
The greenhouse effect currently raises the temperature of Venus, Earth and Mars by the following amounts:
Mars -> +5 degrees
Earth -> +35 degrees
Venus -> +500 degrees
Note that the greenhouse effect for the Earth is just enough to keep us out of a perpetual Ice Age (a little greenhouse effect is good for you). Whereas for Venus, a severe runaway greenhouse effect makes it the hottest place in the Solar System.
Also note that Mars probably had a stronger greenhouse effect in its distant past.  But the large amounts of CO2 were converted to rocks in the early Mars oceans.  The atmosphere thinned too fast stopping the greenhouse effect and the liquid H2O turned to ice (cold death).
The lesson to learn here is that Mars and Venus are exactly opposite in their evolution and the result of the greenhouse effect.  The dynamics of planetary atmosphere's are unstable, and complex so that changes in Earth's atmosphere, even small, are a very serious matter for those of us who need a place to live.
Titan's atmosphere:
One of the thickest atmosphere's in the Solar System (2nd only to Venus) is Titan.  Titan's current atmosphere is 90% N2 and 7% CH4 (methane).  Since Titan formed in the outer Solar System where it is much cooler, and contains more icy materials such as NH3 (ammonia) and CH4.  NH3 is easily separated into N2 and H2 by sunlight.  The N2 is retained by Titan's gravity (see the chart above), but H2 escapes.  Thus, over time, Titan has built up a N2 atmosphere like the Earth's from an original secondary atmosphere that was rich in NH3.
Note that the interaction of sunlight and CH4 induces chemical reactions that build hydrocarbons such as ethane, acetylene, propane; all of which have been detected in Titan's atmosphere. Hydrocarbons can join together to form long molecular chains called polymers.  Droplets of polymers can remain suspended in an atmosphere to form an aerosol (heavy smog) whereas others will sink to form a thick layer of tar on the surface.
Composition of a Secondary Atmosphere:
In summary, the composition of an atmosphere on a terrestrial planet will be determined by the following:
Distance from Sun (surface temperature of planet)
Mass and radius of planet = surface gravity = escape velocity
chemical reactions = different molecules are created and destroyed in various environments, higher temperatures mean faster reactions
geological activity = amount of outgassing, more activity = more outgassing = thicker atmosphere
living organisms = change the composition through their waste products
Why are Terrestrial Planets small and rocky? The primary atmosphere has boiled off leaving the rocky core.  Why did this happen? Distance from the Sun for the primary worlds, distance from warm Jupiter or Saturn for the terrestrial moons.