The best way to keep your cactus from turning brown is to ensure that its environment is one that's conducive to growing a healthy plant. Quarantine new plants and inspect them for pests and disease before exposing them to your other plants. Provide loose, clean, well-drained soil. Underwater, don't overwater, your plants.
If the base of your cactus is turning brown and the stems are soft and yellow, it could be a sign of root rot. Plants with root rot can be hard to save because the rot starts inside the cactus and works its way out, so symptoms aren't usually noticed until the rot is advanced. Stop watering plants with early rot, and try repotting them in well-draining soil. You can try saving a plant with advanced root rot by cutting away all signs of rot along with some of the healthy tissue surrounding it to ensure that it doesn't spread. Use a clean knife and wipe it with alcohol in between cuts. Apply sulphur powder to the wounds. Overwatering or damaged roots can cause root rot.
Scales are small insects that appear like brown spots on cacti because of their hard brown shell coverings. The scales feed on plant juices, weakening cacti and making them look yellow. Spray your cactus with a stream of water to remove scales, or wash your plant with a weak solution of detergent. Use malathion insecticide for large infestations. You can also kill scales by using a cotton swab to dab horticultural oil on each scale. This cuts off the scale's air supply so it suffocates.
Red spider mites are small reddish insects. They're so small that it's easier to look for their webs rather than the bugs themselves. Symptoms include white spots that turn rusty brown and usually appear at the top of the plant. If left untreated, mites kill your cactus by eating the entire outer layer of tissue off your plant. Water cacti from overhead with a strong stream of water to remove mites. Miticides can be used for large infestations.
The appearance of firm, brown, barklike tissue just above the soil of an otherwise healthy plant is a sign of corking and is part of the natural ageing process of cacti. Corking always starts from the base of the cactus and moves upward. If a cactus turns brown from the top down, it's a sign of sunburn or some other problem.
Mild sunburn problems appear as a whitish discolouring, usually at the top and side facing the sun. Severe burns show up as hard brown scars on the burnt surface. Cacti with brown scars have permanent damage. If your plant only has whitish discolouring, you can heal it by moving it into the shade. Cacti that aren't used to being in the sun have to be acclimated to it by providing full sun for a short time each day and then increasing exposure over a period of several weeks. Some species should never have full sun all day.