Space is full of potential dangers—rogue comets, Martiansbags full of astronaut poop, you name it. But if it really came down to it, and you did have to defend yourself against an interstellar attacker, would a traditional gun actually be able to do the trick?
As it turns out, the vacuum of outer space would not be a problem in terms of firing a bullet. After all, guns don't technically need oxygen to work. The gunpowder (or whichever explosive is in the cartridge holding the bullet) 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 work even work ever-so-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.
For example, the International Space Station (ISS) has an orbital speed of roughly 17,000 miles per hour which is 7,600 meters per second. Muzzle velocities range from about 120 meters per second to about 1,200 meteres per second, depending on the gun. Therefore, the orbit of the bullet will differ from the orbit of the astronaut that fired it. In general, firing anywhere in the forward direction of the orbit will result in a more eccentric orbit that will always stay at or above the ISS's orbit. If it's fired against the direction of the orbit, the bullet may end up dipping into the atmosphere and therefore de-orbiting.
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 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.