First of all, do you have a CC? If not, get one.
IMO it's best to find someone experienced with riding to show you the ropes, but if you're like me and have to teach yourself here are the main things to know:
-Always expect slack action! Trains can move unexpectedly and each car will jerk a bit when the train starts moving or stops. If you do not have three points of contact while climbing onto or crossing over a car you can be violently knocked off
-Never step on the coupling between rail cars. That's how you get your foot crushed. Avoid standing between cars if you're not crossing between them for that matter.
-Know what cars you can ride! Don't ride suicide. Find a car that has a platform or porch which you can ride (or hide) on. Never ride loaded cars like lumber cars or gondolas filled with scrap metal. These loads can shift due to slack action and crush riders to death. Grain hoppers are ideal, they have large porches and often have holes you can stash your gear or hide in. One trick you can do if you can't tell if a moving hopper has a safe porch is to throw a rock into it and see if it falls through (this trick also can work for the ends of IM bins). If you're going to ride an open box car, spike the door! If you don't spike the door open, slack action can jolt the door closed which can trap you inside or crush you to death. I also suggest avoiding empty coal cars.
-Try to catch trains that are stopped as opposed to catching on the fly. Trains often 'doubleback' to pick up additional cars as they leave a yard and they will be moving slow and stopping to connect to strings of cars. This is a good time to safely catch a train that's about to leave a yard. Otherwise, many yards and sidings are crew change locations where train crews swap out and a train will be stopped for about 30-60 minutes depending on location.
If you are going to catch on the fly, don't try and catch a train that's moving faster than you can run. Especially if you have to run on steep ballast and there are obstacles around. One trick I like to use is to watch the lugnuts on the wheels. If the wheels are moving so fast that the lugnuts are just a blur and can't be individually counted, the train is moving too fast to catch. If you can catch on the fly, run alongside the train and match its speed. Then, grab onto the ladder with both hands and pull yourself up, maintaining three points of contact as you climb onto the porch. Don't catch box cars on the fly.
Those are the main safety things off the top of my head. I'd also say to make sure you pack enough water, food and warm clothing to last several days. A 2 hour car ride can be an 6 hour ride on junk trains. Plus, your train can stop in the middle of nowhere, and many yards are miles from stores and towns for that matter.
I also suggest investing in a cheap radio scanner. These are useful because you can listen to train crews, yard workers and dispatch. You can gain a lot of useful intel this way. I recommend the Baofeng UV-5R because you can buy one for around 15 bucks.
Anyway, if you got any specific questions feel free to hmu.
Squat the planet. Spange the world!