There are many ways to build a linear encoder - but if you are talking, as I am sure you are, of something that can measure movement to, say, half a thousanth of an inch, I would have thought it in the realms of "too hard" for the average person. I don't know how the ones I have seen even work, but I would imagine some sort of wire matrix laid along the measuring distance. The machinery to lay down such a thing to that accuracy must be specialised.
A simple way, (without me thinking too much) would be to have a "stepper" motor connected to the moving part, so that it rotates, and some sort of "computer" counting the pulses it gives out. If it were free running, as on some of these sepcialist "fifth wheel" measuring devices it would be accurate.
Another way would be a disc which spins as the part moves - with a number of slots in it - and , of course, some form, probably an optical, counter.
The best linear encoders I ever saw were on the coal mine winding gear at the local pit. This was a worm drive on the winding engine moving a marker. When this lined up with a chalk mark on the wall the "driver" knew the cage was accurately aligned. (There were two marks - one to wind with men in, and one to wind with coal tubs in - the latter stretched the cable further). The distance involved was between 200 and 500 meters. Most miners would only "travel" with a driver they knew.