Yes, you can fire a gun on the Moon, despite the absence of oxygen.
A gun "fires" because of a sudden impulse delivered to the gunpowder by the trigger. The gun powder then explodes, imparting a lot of energy to the bullet which shoots out of the gun's barrel. In order to trigger the explosion of the gun powder, you need an oxidizer that will initiate the chemical reaction. On Earth, a common oxidizer is, well, oxygen: that's what makes fires burn and cars rust! Despite the abundance of oxygen on Earth, however, most gun ammunition comes with its own oxidizer "built in", so to speak. The result is that a gun can fire even in the absence of oxygen, such as on the Moon.
This technology is also useful in certain circumstances on the Earth; most notably, sometimes one wishes to cause an explosion on the ocean floor (say, for exploratory purposes), where oxygen is in short supply.
This page was last updated on July 18, 2015.