The following are my thoughts and observations. Other members have different approaches and in some cases, fundamentally different ideas on the subject, so I'm just telling you what works for me. I'm sure the other guys are equally successful, so you can try different things and see what works best for you.
I think it's always better to be filing a sharp chain instead of trying to restore a dull one to a usable condition. For that reason, I touch my chain up after every tank of gas, whether it needs it or not. You'll save more chain over time by sharpening it often, than you will by letting it get dull. And if you do it every time you gas up, you'll never forget to do it. Here's how I sharpen a "sharp" chain; with a dull or mangled one, you have do do a lot more filing, and it may not be worth the effort.
I begin by clamping the tip if the bar into a vise or other holder on my workbench. You need a good light overhead. Hold the file straight and take two or three good swipes on each cutter, pushing up and to the right (towards 2:00 o'clock, more or less). You want the entire length of the cutting edge to be sharp. If you push down on the file or directly to the right, the file will dive down into the body of the cutter and not dress the cutting edge. It will feel like you're sharpening the chain, but you won't be.
Do all of the cutters on one side. Then, flip the saw over, clamp the bar in the vise and do the other cutters. The idea here is to get basically the same angle of attack on both sides of the chain, so that the results are about the same. If your angle is off on one side or the cutters aren't equally sharp from one side to the other, the chain will cut a big arc through big wood. You've probably had that happen.
Chains also have depth gauges, aka "rakers." These control the bite that the cutters take into the wood. If your rakers are filed too low, the chain will stall or kick in the cut. If they're too high, it won't get enough bite and you'll get fine sawdust instead of healthy chips. You can buy a raker gauge for about $5 that will tell you how much to file off each raker. I generally just take the rakers down after 5 or 6 sharpenings, depending on how the saw is cutting. But for a novice, I'd recommend going to a sawshop and buying a raker gauge. Be sure they show you how to use it, and make sure you get the right one for your chain, because they're all different.
Learning to file a chainsaw chain takes practice, but once you get the hang of it, there's no better way to sharpen a chain, IMO.
Here's a link to an old thread showing the saw in the vise.
https://www.hearth.com/talk/threads/1264/