Might be a silly question, but I’ve always wondered how this works.
Pressurized cabins have electronic systems in place to regulate breathable air. The co2 is moved out of the pressurized cabin by the use of an outflow valve and fans, which are electronically controlled, while breathable air is pumped into the cabin through a series of devices that cool the air and regulate oxygen levels within the cabin.
Others have answers about how they regulate oxygen on an airplane, but I want to point out how long you can actually continue to breathe the same air. If you were locked in an airtight coffin, that minimal amount of air around you is enough to keep you alive for 5 hours.
If an airplane was sealed airtight, it would probably still maintain a full plane of passengers for about 12 hours.
Many aircraft also implement liquid oxygen (LOX) because high altitudes often lack enough oxygen to support life, or I guess consciousness.
Edit: I just reread what I wrote and I sound like an idiot, so to clarify the lox is primarily used for life support and not the main source of oxygen. There is oxygen at commercial heights, the air is just thinner and that’s why they pressurize aircraft.
While most of these answers are satisfactory, I feel like I should clear it up a bit. Air at higher altitudes aren’t necessarily lacking oxygen content, it’s just that the air is so thin we can’t get enough of it in a breath so we suffocate and die. Passenger planes are constantly taking air in at altitude and pressurizing the cabin. An outflow valve is constantly letting air out at a controlled rate, to maintain a set pressure. So as you fly you are constantly supplied with fresh air that’s been pressurized for breathing, and the plane is constantly farting out it’s outflow valve 🙂
It’s a mixture of fresh air from outside, and recirculated air. Here’s an interesting article that explains.