You will earn a new level once you complete each mission; you will also gain 40xp for completing various conversations, alignment actions and hacking. You don’t earn experience for killing enemies so just make sure you complete as many free-roam missions as possible. You shouldn’t have any issues with leveling up unless you try to rush through the main story. It is possible to attain this in one playthrough if you do all the side missions.
Avoid talking to the Illusive Man as much as possible until you level up; he will normally give you a mission to do which you have no choice in doing. The mission will start and there only way to end your mission will be to complete it.
It takes 1000 experience to level up. Here are the values for each kind of mission:
Story Mission: 1000 EXP
Loyalty Mission: 750 EXP
Anomaly Mission: 125 EXP
Miscellaneous Side-mission: 40 EXP
Note: Once you have completed Mass Effect 2, you will earn a 25% experience bonus on all subsequent characters, making this easier to attain.