Adjust the limit screws for both the smallest cog and the biggest cog making sure the derailleur doesn't go too far and hit for example the spokes.
One of the best way to do this is to set to the highest or lowest (whichever you are adjusting) gear.
Example below is for adjusting the smallest cog.
Turn the pedals and turn the limit screw so the derailleur is in the gear before the smallest gear
After this is done the limit screws adjustment is finished and the next step is to adjust the barrel adjuster.