M4 front end disassembly guide by me.
Your M4 may differ slightly, but should mostly be the same.
Start out by separating the upper receiver from the lower receiver and remove the inner barrel and hop-up unit.
Next remove the hand guard and flash hider.
After that the sling mount must be removed in order to gain access to a small set screw on the underside of the sight. Remove the set screw.
The next step is to remove the two pins on the bottom of the front sight. I pounded them out with a small Phillips head screw driver. They're usually pretty hard to get out. Try pushing them out from both sides, one way will be easier than the other.
After you finish all that you should be able to slide the front sight, the gas tube, and the front ring for the hand guard off of the barrel.
If you're looking to remove the barrel you have to unscrew the barrel nut. The best way I've found to break it loose is take a pair of needle nose pliers and grab between the "teeth" of the barrel nut and turn counter clockwise. After it breaks loose you should be able to loosen it the rest of the way by hand.
After the barrel nut is loosened all the way the barrel should slide right out of the receiver and the barrel nut can slide off of the barrel.
The barrel nut consists of four parts. The nut itself (the part with the teeth), a spring, the grip that slides over the end of the hand guard once they're locked into place, and a C ring to hold it all together. When you reassemble the front end, the notches on the grip, the C ring, and the spring have to be lined up so the gas tube can slip through the barrel nut assembly and into the receiver.
So there you have it, the idiots guide to M4/M16 front end disassembly.