Almost all musical instruments require tuning, with the possible exception of certain percussion instruments. The guitar, as an instrument made from natural materials, and with a natural degree of tension stored up in the strings, needs retuning on a fairly frequent basis. This is especially important for a guitar since each of the six or ten strings needs to be in tune with the remaining strings. Whilst many other instruments still sound fine if slightly out of tune but being played alone, a guitar needs to have all of its strings independently tuned to ensure a complimentary sound is created, and that all the notes are in harmony. The fact that the strings of a guitar, especially electric guitars and steel strung guitars, are under so much tension, this does naturally pull on the headstock and cause a slight release of tension over time, and if the instrument is played frequently, even the pressure of the fingers against the strings pushing them into the fret causes enough extra tension to cause the strings to loosen.
Whilst each loosening may very well not be particularly noticeable, over time any discrepancy in tuning between the strings and the sound can very quickly become quite unpleasant to hear. Again, unlike many instruments the guitar is unusually when it comes to tuning as it is what is known as a transposing instrument. Basically this means that the pitch of the instrument is not the same as the way it is written on the sheet music. On sheet music the octave is usually a full octave higher than the guitar sounds, or put another way, a guitar is played an octave lower than the sheet music has it written.
There is not actually a single correct way to tune a guitar, and many methods are used. The standard, known as standard tuning, means that the strings are tuned in such a way that the lowest note they can reach is a low E, and they are tuned to reach a full two octaves higher, with a high E being the top note. In most cases, once the first string has been tuned, a guitar can then be tuned simply by comparing the notes on the first string with those on the second. So, for example, by playing a D# on the first string, and then holding the finger on the second string where the same D# can be found, this string can be tuned by ear by simply switching between the two strings and playing the same note until the second string sounds the same as the first.
The echoes of the first string's resonance should still be audible whilst the second string is playing, and this overlapping of the echoes provides a very clear indication of whether the strings are in harmony and tuned correctly. Once the second string is tuned, it can then be used in the same way to help tune the third string, the third the fourth, and so on. Although tuning using the ear alone is usually the way in which a guitar is tuned, some people find this more easy than others. Regardless of whether one is a musician or not, people do have different abilities to detect harmony and identify if the pitch is wrong, or an instrument is badly tuned. More musicians than non musicians can do this, but this is simply through practice.
Many beginners find that they can achieve the same tuning quite easily with no prior musical knowledge, as long as they have a means by which the first string can be correctly tuned. This is possible by either comparing it to a note played on another instrument, such as a piano, or by having a pipe whistle or tuning fork to play the note. Today there are electronic means to identify if a guitar is in tune, by playing a note, and having the electronic tuner identify the exact frequency of the resonating wavelength. This can be compared to a scale, or even displayed as whether the note is recognised, correct, flat or sharp.