For "near by "objects on can use parallax: look at the object on a given date then again 6 months later and see how much it shifts against the back ground stars. Simply triangulate using the known distance from earth to sun as half the side of a triangle.
For "moderate" distances one can rely on certain variable stars that always have a known brightness. Then when you locate such a star, note how dim it is and calculate how far away it would have to be to have that brightness level.
For "far" distances one can measure the red shift. That is to say, on the large scale everything in the universe appears to be moving away from us. Further away object move faster than nearby objects. Thus if you can measure how fast something is receding from us you can tell how far it is. The technique for measuring speed like this is to measure the Doppler red shift.