I'm going to bump a topic. Want to gain or lose weight. Read thru it, as it's pretty thourough. Once your done there, dl a calorie counter. Visit Acaloriecounter.com and also head over to bodybuilding.com and ready thru jim stoppani program shortcut to size. You'll have all the knowledge needed at that point.
As for how. Well it takes a long time bro. Fall in love with the pain, and be patient. Don't expect miracles, you can not reverse a life of not lifting by doing some workouts.
How many times you want to workout is up to you. Eat healthy protein like lean meats, they help build muscle. Eat a balanced diet. Do weightlifting. Don't start with too heavy weights. While lifting, I'd suggest u start out lifting lighter weights while doing longer reps. Increase the weight as you get used to it. Then eventually lift heavier weights with shorter reps. You have to be determined and have patience