Park tool has a step by step
rear derailleur alignment page. It starts with setting the high and low limit screws, then adjusts the shifting.
Getting the limit screws set correctly will keep the chain from being shifted off the small cog, or even worse, shifted off the big cog and into the spokes. You can destroy the derailleur, frame and spokes that way.