If you’re in space and you needed to defend yourself from an interstellar attacker, would a traditional gun can do the trick? How would a bullet fired from a gun behave in zero or low gravity?
The gunpowder is completely self-contained and does not depend on the surrounding atmosphere. It has an oxidizer mixed with the fuel and is perfectly capable of firing in a vacuum. Even the primer, which is struck by the pin of the firearm, is completely self-contained and will work in a vacuum.
In fact, the gun will even work slightly better in outer space, because the bullet won’t have to push and compress the air in the barrel as it exits the gun. Since there’s no air to slow down the bullet as it travels, the range of the gun would essentially be infinite. Of course, the the trajectory would curve eventually, since it would probably still be in orbit, but it would have a notably different orbit than the gun itself or the person that fired it.
There is no need to “push” against anything for a gun to work. The difference between the mass of the bullet and the mass of the gun—plus the person holding the gun—will ensure that the bullet gets almost all the kinetic energy of the explosive (even though they both get the same momentum due to conservation of momentum).
However, assuming that the astronaut is floating freely in space, if the line of the barrel does not point through the center of mass of the gun/astronaut, the firing of the gun will impart some small angular momentum to the astronaut.
In a nutshell, yes you can fire guns in space. But do you really have to?