What once took strong backs and stout spirits was replaced by bulldozers, graders, compactors and side dump cars. Contemporary railroad construction has truly become a ballet of man and machine.
The surveyor begins the process, marking the area where the tracks will appear. Modern Global Positioning Systems (GPS) are used to obtain pin point accuracy.
Next, the land is often cleared of larger trees using hydraulic "feller bunchers" or similar specialized equipment. Brushcutters are used to slash the smaller ones. Excavators and front loaders are used to remove overburden. Dump trucks, dozers and scrapers make rough grade.
Various types of compacting equipment is utilized to compact the fill section. 8 1/2' track ties are placed 19" OC using cranes and tie handlers. The ties can be purchased with plates already affixed.
115# rail in 39' or 80' lengths (or longer for continuously welded rail-CWR) is placed by crane. Hydraulic or gasoline powered tools are used to saw and drill rail. Bolt machines are used to tighten the joint (angle) bar bolts. Spikes are machine driven. Rail anchors (to resist longitudinal rail movement) are machine applied. Sometimes track is laid in pre-made panels, 39' typically. After the panels are laid one rail is pulled lengthwise to provide the requisite stagger (so you get your "clickety clack").
A work train dumps ballast onto the "skeleton" track using hopper or dump cars. Ballast regulators perform precision ballast dressing and final brooming of the track. Tamper/liners raise the skeleton track onto the ballast while vibrating the ballast into the voids under the ties. The track is lined both vertically and horizontally by these machines.
Track guys are always wanting to raise track to improve it. They want more or better ballast under the ties to improve drainage or resistance to undesirable track movement (sunkinks, settling, etc). This can create quite a problem for the bridge building guys. Bridges shouldn't be raised unless absolutely necessary. For example, the 700' main span across the Tanana River at Nenana (The Mears Bridge) would be tough to raise. Anyway, a machine called an "Undercutter" can be used to remove/replace or even recycle poor quality (dirty) ballast from under the ties without any resultant track raise.