Cotter pins are used with slotted or castle nuts to lock the nut in position (preventing it from loosening or coming off in service). When used, the stud or bolt has a hole in it. When the nut is tightened, you align the slots with the hole so that a pin can be inserted. After the cotter pin is inserted through the nut and bolt, the legs of the cotter pin are bent over to lock the pin in place.