You may be able to see the adult beetles and easily identify the grubs. The adults are black beetles about 1 to 1 1/4 inch long. The larvae of this insect are responsible for the majority of the damage as they burrow into the soft tissues of the cactus. The burrowing creates a frass or waste area that is black at the burrow site. The larvae can burrow into the roots of the cactus and cause it to collapse and die.
Vine weevils are a prevalent pest of cacti. The insects are large gray bugs which have some resemblance to beetles, but with narrower bodies. They lay eggs in the soil around the cacti which hatch to become fat white grubs with brown heads. They burrow from their hatching place to the roots of your cactus and then up the stem. Their feeding activities will kill the cactus. You can see signs of adult activity as they feed on the edges of leaves or pads on the plant. You can spot the larvae on the roots when you re-pot. Hand remove them or treat the plant with gamma benzene hexachloride.
Sciarid flies are hard to spot. They are tiny black flying insects also called soil midges. The flies lay their eggs in moist soil, especially any that has a peat base. If a little cloud of flies rises up when you touch the soil, you likely have sciarid flies. Their larvae are translucent and eat old and decaying material. Occasionally they may attack the roots of the cacti. Sciarid fly larvae are mostly damaging to seedling cacti and may be prevented by keeping soils dry.
Often it is too late to save your cactus once you notice grub activity since the grubs can be deep inside the core tissues. Prevention is your best weapon against grub attacks. Before you purchase a plant inspect it thoroughly for holes, soft or discolored spots and physical signs of the grubs. Keep a new plant separate from your other plants for a few weeks to verify its health and prevent introducing bugs to your cacti collection. Keep debris and dead plant material cleaned up so there are no hiding places for insects or their larvae.