Nut (string instrument)
A nut, on a stringed musical instrument, is a small piece of hard material that supports the strings at the end closest to the headstock or scroll. The nut marks one end of the vibrating length of each open string, sets the spacing of the strings across the neck, and usually holds the strings at the proper height from the fingerboard. Along with the bridge, the nut defines the scale lengths (vibrating length) of the open strings. The nut may be made of ebony, ivory, cow bone, brass, Corian or plastic, and is usually notched or grooved for the strings. The grooves are designed to lead the string from the fingerboard to the headstock or pegbox in a smooth curve, to prevent damage to the strings or their windings. Bowed string instruments in particular benefit from an application of soft pencil graphite in the notches of the nut, to preserve the delicate flat windings of their strings. Etymology
The word may have come from the German Nut (pronounced "noot"), meaning groove or slot. The nut, however, is called a de:Sattel ("saddle"; also Obersattel) in German, whereas the part of a guitar known as the saddle in English, the surface of the bridge on which the strings rest, is called a de:Stegeinlage or Steg, in German. In French, the nut is known as a :fr:sillet, which, like German, can also translate to mean saddle. The Italian term, capo tasto (or capotasto; "head of fretboard"), is the origin of the capo. Variations
Not all string instruments have nuts as described. The nuts on some instruments are notched deeply enough that they are just string spacers. These instruments use a zero fret—a fret at the beginning of the scale where a normal nut would be that provides the correct string clearance. The zero fret is often found on less expensive instruments, as it is easier to set up an instrument this way. However, a zero fret also makes the sound of the open string similar to fretted notes. A conventional nut can make open strings sound slightly different—and for this reason some high-end instruments use a zero fret. String slots in a nut without a zero fret must be cut to the proper depth to make string height correct. Strings that are too low at the nut can buzz against the frets, and too high throws off intonation of fretted notes. Some fretted instruments have a compensated nut. This type of nut provides better average theoretical intonation across the instrument, although this improved accuracy may be below the threshold of human ability to hear it and may also be below the threshold of uncontrollable note-to-note intonation variability. The principle given that strings are different thicknesses and have different tensions, the temperament of each fret is not 100% accurate for an equal temperament instrument. This is especially evident on the first few frets of an electric guitar. Many guitar players notice how 'open position' chords (Such as E, A, C, D and G) never sound in tune with each other. A compensated nut aims to correct this, by staggering the starting position of each string according to thickness. While not a complete solution such as a true temperament fretboard, there is a noticeable difference in tuning within chords. Many guitar companies, such as Music Man, and ESP include compensated nuts as standard on most of their instruments, and companies such as Earvana provide retrofittable types. Another type is a locking nut. This nut—usually used in conjunction with a locking vibrato system such as a Floyd Rose or Kahler—clamps the strings against the nut. This improves tuning stability when using the vibrato bar. A drawback however, is that the locking nut must be loosened using an Allen wrench to tune outside the range of the fine tuners on the bridge (if present). The erhu does not use a hard nut to define the vibrating length of the open string, but rather a qiān jin (千斤), a loop of string, or, less commonly, a metal hook. Some guitars have a rolling nut. In this design, made popular by Fender, the strings sit on roller bearings instead of nut slots. The rollers let the string freely slide or roll through the nut. The roller nut helps keep the guitar in tune by preventing the strings from getting stuck in the nut. Keyboard instruments
The term "nut" also refers to bridges on certain keyboard instruments. On harpsichords, it designates the non-sounding bridge located near the tuning pins away from the player. On virginals, the term usually designates the bridge on the left side, away from the tuning pins. The term is not always applied consistently. References 

String instrument construction
Musical instrument parts and accessories