Until recently, astronomers recorded spectra directly onto photographic film. Today they are more likely to record them directly into a computer. They classify stars by comparing recorded spectra with reference spectra, until a match is found.
The spectra below are reference spectra for G and K main sequence stars. The Sun is a G2V star.
The spread of colour intensities enables astronomers to determine the temperature of a star.
The amount of light enables them to determine the stars size.
The lines in the spectrum lines enable astronomers to determine the composition of stellar atmospheres and dust clouds. Doppler shifts in the position of the lines enable them to determine the velocity of the source in relation to Earth.