Before you try to adjust your rear derailer, you should really make sure it isn’t bent. The rear derailer is the most fragile and exposed part of a bicycle, and they are always getting bonked.
Step 1: Make sure the rear derailleur is shifted all the way down into the smallest cog.
Step 2: Turn your barrel adjuster all the way tight so that you have room to adjust it later.
Step 3: Adjust the high limit by rotating the screw on your derailleur marked “H” so that it lines up with that smallest cog.
Step 4: Tighten the tension in your cable by unscrewing the cable anchor, pulling the cable tight and screwing the anchor back on tight.
Step 5: Shift your rear derailleur into the 4th or 5th cog.
Step 6: To adjust the index, turn your barrel adjuster so that the derailleur pulley lines up underneath the correct cog. With a Shimano rear derailleur, you want to line up the pulley slightly inboard of the cog. Do some practice shifts to make sure it is adjusted properly.
Step 7: Shift your rear derailleur into the largest cog.
Step 8: Adjust the low limit by rotating the screw on your derailleur marked “L” so that it lines up with that largest cog.
Step 9: Adjust the B-tension screw so that the pulley on the rear derailleur is as close to the largest cog on the cassette as possible without dragging.