Item #1
Firing a gun can be done anywhere. All you need do is operate the firing mechanism. In a pistol, rifle or revolver, it's finger-operated lever system--a trigger; in larger guns, like a cannon, it's different but the principle is the same. Whether the projectile emerges from the muzzle of the weapon depends on where the propellent is located.
I assume you mean the pistol or rifle type of 'gun.' In such weapons, the projectile (bullet) is attached to the open end of a metal casing (shell) that contains the propellant (gun powder). Operating the trigger causes a firing pin to strike the cartridge. The percussive force initiates a chemical reaction (explosion) in the propellant. Since that chemical reaction is independent of the environment outside the cartridge, the expanding gasses drive the projectile from the casing and out of the muzzle of the weapon.
Item #2
Firing a gun inside a ship in space is probably not a very good idea because of the danger of puncturing the hull. I worry every time I see projectile weapons, especially machine guns, fired in space ships as in Stargate-SG1 or Battlestar Galactica. But of course, all is well, since it's just TV.
But let's say we have a bullet proof space ship and let's assume it's far enough from any planet so that there is negligable gravity. There is someone aboard who likes to make loud noises, has a pistol, aims it at the opposite wall and presses the trigger.
Boom! Faster than he likes, the bullet strikes the opposite wall. It bounces off and caroms about the cabin until enough of the kinetic energy imparted by the explosion is absorbed by the ship and the bullet falls to the floor, hopefully without first passing through our maniac. Although, come to think of it, if the bullet did pass through our maniac, he'd be out of the picture and we could get on with the story.
What happens to the environment? To an observer outside the spaceship, nothing happens; the ship just continues doing what it was doing before the gun was fired. That is unless the bullet-proofing fails. Then we need to discuss the principles of rocket motors. Maybe another time.
But what happens inside the ship to the maniac at the instant the gun is fired? See Julie's response above. She's right. If our maniac is floating in the air of the cabin, firing the gun will indeed push him backward. But he won't go back very fast, since there is something called inertia: An object at rest will tend to stay there until a force is applied to it. Our floating maniac is surrounded by air, and the force of firing the gun must not only move the maniac but also the air. He'll move, but not anywhere as fast as the bullet does. If he was firing a machine gun though, he'd not only be rapidly in the company of many flying bits of metal, he would soon find himself pressed against the bulkhead behind him. If there is no air inside the spaceship and the maniac has amazing breath control (or is wearing a space suit), he just moves a little faster. Kind of like putting super grease in Julie's roller skate wheels.
To be safe, give him a ray blaster.
And teach him that aiming and firing such a weapon with single bursts of red light is silly; just press the trigger and wave the death ray all about in the general direction of your opponent.
And don't fire the ray blaster at a mirror.
And wear your space suit.
Or take a different space liner to the Restaurant at the End of the Universe...