The same as opening a locked door when you don't have a key. Hit it with something until it breaks. Be careful not to do this close up with barrels marked XXX, though.
The best choice for smashing open barrels is to have 1 point in unarmed combat (or wear a Brawler's Ring). That way you don't damage a weapon while pounding on it and also don't take any damage yourself. If you're a mage, various spells will work. Just check the description to be sure they function against inanimate objects (the funny one in this is that you cannot target an inanimate object with Compress Atmosphere, but if a live target is next to an inanimate target, the spell will damage both).