How does Carbon Dioxide have a degree of freedom of 6?
There are always 3N total independent degrees of freedom for a molecule, where N is the number of atoms. These come about because when each atom moves, it has three independent degrees of freedom: its position in each of the x, y, and z directions.

Now, having independent degrees of freedom for each atom isn't all that useful. Instead, we can make combinations of different degrees of freedom. The important thing when doing so is that the number of independent degrees of freedom are preserved: it's just that what a particular degree of freedom does to the atoms changes.

The standard breakdown of degrees of freedom subtracts out global movement in each of the three directions. So you have 3N total degrees of freedom, but you can set aside 3 of them as translation of the whole molecule in each of the x, y and z directions, leaving (3N-3) degrees of freedom. 

Likewise, it's standard to subtract out the whole molecule rotation. For most larger molecules, there's three different degrees of rotational freedom: rotation around each of the x, y, and z directions. But for linear molecules like $\ce{CO2}$, one of those rotations (around the axis of the molecule) doesn't actually change the position of the atoms. Therefore it's not a "degree of freedom" which counts against the 3N total. So while for non-linear molecules there are (3N-3-3) = (3N-6) degrees of freedom which are independent from the global rotational and translational ones, for linear molecules there are (3N-3-2) = (3N-5) degrees of freedom which are independent from the global rotational and translational ones. -- A quick clarification. The reason why we ignore this rotation is not because the center of mass doesn't move. The center of mass doesn't move for any of the global rotations: in the typical assignment of degrees of freedom the axis of rotation goes through the center of mass. Instead, the reason the rotation is ignored is that none of the atoms move due to the "rotation". 

So since $\ce{CO2}$ has three atoms and is linear, it has 3*3 - 5 = 4 degrees of freedom which are independent of the global rotation and translation. We call these the vibrational modes. There's different ways you can decompose them, but the most useful one is 1) the symmetric stretch (both oxygens going out and in at the same rate while the carbon sits still), 2) the asymmetric stretch (the carbon going back and forth while the oxygens sit more-or-less still), and 3&amp;4) two different out-of plane bending modes. (If the molecule is aligned along the x-axis, one each where the carbon moves in the y and z directions.)

That's it for $\ce{CO2}$: any movement you make - any position you put the atoms in - can be thought of as a combination of those nine movements (three global translations, two global rotations, and four internal vibrations/bending).