While there are no local or commuter trains that help with getting around Hanoi, the Vietnam train system is extensive, cheap, and safe.
You can take a train up to Sapa (the overnight train is recommended), out to Haiphong on the coast, or all the way south to Ho Chi Minh City. Tickets are classed, in order of increasing comfort, as “hard seat,” “hard sleeper,” and “soft sleeper.” The latter two include sleeping berths that make long-distance travel pleasant and relaxing.
You can buy tickets at the Hanoi train station, or at any of the many travel agencies in the old quarter, or even at most hotels. You’ll have to buy your tickets in advance, and hold on to them to find your berth once you’re on board!
With some tour operators, such as Pumpkin Travel (http://www.et-pumpkin.com/), you can simply call and request where and when you want to go and someone will go buy the tickets and deliver them to your door.
The Vietnam Railway has schedule and fare information on their English language website here: