When it comes to undesired noises, silencing guns is the same thing as silencing incessant yammerers. It all comes down to dealing with hot gas.
When a cork pops out of a champagne bottle, a lid pops off an over-heated jar, or a bullet shoots from a gun; they all result in a sound. High pressure gas is released so suddenly that we can hear the waves of pressure it makes as the waves travels through the air.
Sparkling wine is bottled under pressure. Jars lids pop off because the air inside them heats and expands. A bullet explodes from a gun when gunpowder behind the bullet is ignited. It burns and releases gases violently and quickly. The bullet is the "lid," sitting between the gases and the easiest point of exit from the gun barrel, and so it shoots out into the air. The gas behind it crashes into the air, making the 'bang' that most people associate with gunshots.
Silencers, or "suppressors," are all about finding ways to reduce the speed, volume, and temperature of that gas. They do so using various structures. One structure is just large chamber attached to the end of the gun barrel. This gives the expanding gas somewhere to expand into. It's a little foyer that some of the gas can mill around in, instead of shooting all of it out of the gun at once. Another is a series of small chambers, almost a honeycomb made of metal. The many chambers make the flow of gas choppy, interrupted by diversions. The honeycomb also makes the gas flow over a large, metal surface area. Metal absorbs heat very well. All the heat that goes into the metal comes out of the gas. Since heat makes gas expand, losing some heat will make it contract. That contraction means less pressure, and that means less of a bang.
But not none of a bang. When most guns fire, they create not one bang but two. The first is the expanding gas. The second is a sonic boom as the bullet breaks the sound barrier. There isn't anything a silencer can do about that.
Some silencers, specifically the ones in movies, can't do anything about either. Many movie silencers are just objects jammed on the end of the gun. Sometimes they're solid, like potatoes, or sometimes they're filled with things that supposedly are going to muffle the sound.
In the 2007 film Shooter, a silencer was made out of a can filled with socks. It would have been better if the socks had been left out, since all they would do was take up space that the gas could have expanded into. Most packing materials are useless.
The one packing material that can be helpful when making a silencer, is metal. It won't allow the gas to expand, but it can soak up some extra heat. Steel wool, wire, filings, anything that can suck some heat out of the expanding gas.
Anyone hoping to become an assassin, one truly recession-proof job, is out of luck, though. Suppressors are a less popular term than silencer, but they're a more accurate one. Many sites compare a suppressed gunshot to the sound of a door slamming, or a car backfiring. They can't silently crumple a look-out while an enemy camp is asleep. The most they can do is make people in a fairly noisy area, not too close to the gun, not immediately recognize the sound as gunfire. So, if stealth is a factor, better pack a crossbow.
Note: This is an io9 flashback. The original post ran back in 2010, when Bond movies ruled the world.