Why doesn't the oil in the cylinder of a hydraulic excavator spill?
When you take a faucet apart, you can see a round rubber seal that keeps water from spilling. The cylinder in a hydraulic excavator does the same thing. The part called "O-ring" prevents oil from leaking, and the part called "urethane seal" prevents soil and other stuff from coming inside.
The cylinder is a shiny silver color because the surface is extremely smooth. Even a small bump on the cylinder can cause oil leak.