They are called riffs or runs...
Learn your scales in all keys and this will get you started in the right direction. Riffs/runs can lead you into chords or be played along with chords. What is your specific question about this?...If you do a search, you will find numerous discussions on riffs/runs.
Be Blessed!