Just like any other plant, your cactus can develop a fungal infection. It is usually a fairly simple issue to get rid of cactus fungus, but if the fungus has grown as a result of a wound to the plant, you might have a tougher time eradicating the problem. Fortunately, cactus fungus is susceptible to natural methods and commercial fungicides, so it can usually be treated before it kills the plant.
Remove exposed and infected plant material. If the cactus fungus is growing where a leaf has broken off, then you will need to cut off the infected area. Cut behind the infection so that you can throw the fungus away entirely.
Swab the fungus with rubbing alcohol. In many cases, fungus on cacti is accompanied by secondary infections of mealy bugs or gnats. The rubbing alcohol will kill these invaders as well as weakening or killing the fungus. Make sure that you actually rub the fungus off the cactus when you are applying the rubbing alcohol.
Treat isolated infections with cooking vinegar. If a single leaf has been infected, then cover the surface of the leaf with vinegar. This will kill the fungus and cause the leaf to drop off naturally so that you do not expose the interior of the cactus to additional infection.
Dust the plant with Bordeaux mixture. This is a fungicide that is safe to put on the surface of the cactus as well as on exposed interior areas where you have been forced to cut. It will kill the fungus without hurting the plant.
If you fear that your cactus has mould or mildew, then you can try not watering the plant for a few weeks to see whether this kills off the infection. Keep the cactus away from other plants and in a dry area if you try this.