The nut works with the shaft or the sleeve, and the threads have to match in both diameter and pitch. On an adapter sleeve, the nut and washer come as part of the set, so if you replace only the nut, identify the sleeve as well. On a threaded shaft end, the machined thread is what counts, and measuring it is worthwhile when there is no drawing.
Look at the washer when you take things apart. A sheared inner tab, or outer tabs fatigued from being bent several times, mean the washer should be replaced along with the nut. Use a hook spanner or impact spanner of the right size to tighten and loosen; driving a punch into the slots deforms the nut and makes the next removal harder.