Unload your gun, all that.
Take the upper off, take the bolt carrier out.
Once you take the handguards off, you will have to use a punch to push out the pin that holds the gas tube (it's on the 'cross bar' part of the front sight). Once that pin is out, the gas tube, which will be mostly stuck if you shoot much, will have to get worked loose. Push it (the gas tube) back towards the upper until it's clear the front sight post, then rotate the tube so you can work it past the front sight and pull it forward towards the muzzle.
Once the gas tube is out, you are free to wrench on your nut (barrel nut, of course).
Once the nut is off, the barrel is a slip-fit into the upper; no twisting, pulling or anything. A short pin on top of the barrel fits in a slot to index it. That's it. Easy day. It may come out, just slide it back in. You can't put it in too far, or not far enough. This part is pretty hard to screw up.
Put anti-seize (or grease, or whatever) on your threads before re-installing. You may torque it to the specs in the TM, but there are those that say you only need to snug the barrel nut, not torque it, as the gas tube prevents in from unscrewing. Make sure the holes in your new barrel nut line up and give your gas tube a straight shot to the gas key on the bolt carrier. You may want to ask around as to what might be best for your situation.