How to constrain an object to one of it's local axes?
You would use constraints. There are all kinds of constraints, tracking constraints, IQ constraints, spline constraints, camera constraints. I think you're looking for Limit Location, though. Check here:

https://docs.blender.org/manual/en/latest/rigging/constraints/index.html