The easiest way to experience the Doppler effect is to listen to a moving train. As the train moves towards a person, the sound it makes as it comes towards them sounds like it has a higher tone, since the frequency of the sound is squeezed together a little bit. As the train speeds away, the sound gets stretched out, and sounds lower in tone. The same happens with light when an object that emits light moves very fast. An object, like a star or a galaxy that is far away and moving toward us, will look more blue than it normally does. This is called blue shift. A star or galaxy moving away from us will look more red than it would if the source were not moving in our frame of reference. This is where red shift got its name, since the colors are shifted towards the red end of the spectrum.
The reason astronomers can tell how far the light gets shifted is because chemical elements, like hydrogen and oxygen, have unique fingerprints of light that no other element has. Astronomers use spectroscopy to analyse the light from an object (galaxy or star). Once they know that, they check to see the difference between where the spectral lines are compared to where they normally are. From that, they can tell whether it is moving toward us or away from us, and also how fast it is going. The faster it goes, the farther the spectral lines are from their normal position in the spectrum.