Astronomers use different methods for measuring the distances of stars. As you may imagine, cosmic distances can be tricky to pin down accurately given how impressively far apart everything in the universe is, but with the right measurements and a little mathematical prowess, it can be done.
One method for measuring stellar distances is parallax. Parallax refers to the apparent change in position of a star that occurs as the Earth orbits the sun. The shifts are tiny given that we're dealing with such large distances, and they grow smaller as that distance increases. That's why parallax, while useful, is limited to our cosmic neighborhood. Anything too far out requires other means of measurement to determine distance.
|By P.wormer (Own work) [CC-BY-SA-3.0 or GFDL], via Wikimedia Commons|
If you're interested in learning how to determine parallax, you can watch these videos. They spell out the process as clearly as possible and should give you a good idea of how it's done. Yes, they're a bit long, but they're packed with information! (And yes, I personally watched all of them all the way through!)