A nut is a type of fastener with a threaded hole. Nuts are almost always used in conjunction with a mating bolt to fasten multiple parts together. The two partners are kept together by a combination of their threads' friction (with slight elastic deformation), a slight stretching of the bolt, and compression of the parts to be held together. Square nuts, as well as bolt heads, were the first shape made and used to be the most common largely because they were much easier to manufacture, especially by hand.
Bolts are designed to pass through an unthreaded hole in a component and be fastened with the aid of a nut, although such a fastener can be used without a nut to tighten into a threaded component such as a nut-plate or tapped housing. Screws in contrast are used in components which contain their own thread, or to cut its own internal thread into them.