Whenever you gain experience, all abilities on your active skill bar earn experience for themselves and – in case of race, class and some Open World abilities – also for the respective skill line itself. You don't have to actually use the ability, but you'll usually do so anyway.
Some skill lines level in a different way, which is always explained in their experience bar's tooltip.
For example, to gain experience with the Mages Guild, you'll have to find lore books (blue glowing) and read them. The Undaunted want you to kill enemies in f player group instances, and the Warrior Guild wants you to kill Werewolves and Daedra.
Armor and weapon skill lines are leveled by equipping their respective items.
Legerdemain is only leveled by committing crimes (stealing, opening locks) and both Dark Brotherhood and Thieves Guild require you to complete their respective main story arcs.