The answer to 'how to replace light fixture' is to first turn off the power to the fixture at the circuit breaker. Then, remove the old fixture by unscrewing it from the electrical box and disconnecting the wires. Install the new fixture by connecting the wires (black to black, white to white, and green/bare copper to the green screw or box) and securing the fixture to the electrical box. Finally, turn the power back on and test the new fixture.
It's important to take safety precautions when working with electricity, such as turning off the power, using insulated tools, and avoiding touching bare wires. Replacing a light fixture is generally a DIY-friendly task, but if you're not comfortable working with electricity, it's best to hire a licensed electrician.