We present a new catalogue of 55 121 groups and clusters centred on luminous red galaxies from Sloan Digital Sky Survey Data Release 7 in the redshift range 0.15 ≤z≤ 0.4. We provide halo mass (M500) estimates for each of these groups derived from a calibration between the optical richness of bright galaxies (Mr≤−20.5) within 1 Mpc and X-ray-derived mass for a small subset of 129 groups and clusters with X-ray measurements. For 20 157 high-mass groups and clusters with M500 > 1013.7 M⊙, we find that the catalogue has a purity of >97 per cent and a completeness of ∼90 per cent. We derive the mean (stacked) surface number density profiles of galaxies as a function of total halo mass in different mass bins. We find that derived profiles can be well described by a projected Navarro–Frenk–White profile with a concentration parameter (〈c〉≡〈r200/rs〉≈ 2.6) that is approximately a factor of 2 lower than that of the dark matter (as predicted by N-body cosmological simulations) and nearly independent of halo mass. Interestingly, in spite of the difference in shape between the galaxy and dark matter radial distributions, both exhibit a high degree of self-similarity. We also stack the satellite profiles based on other observables, namely redshift, brightest cluster galaxy (BCG) luminosity and satellite luminosity and colour. We see no evidence for strong variation in profile shape with redshift over the range we probe or with BCG luminosity (or BCG luminosity fraction), but we do find a strong dependence on satellite luminosity and colours, in agreement with previous studies. A self-consistent comparison to several recent semi-analytic models of galaxy formation indicates that (1) beyond ≈0.3r500 current models are able to reproduce both the shape and normalization of the satellite profiles, and (2) within ≈0.3r500 the predicted profiles are sensitive to the details of the satellite–BCG merger time-scale calculation. The former is a direct result of the models being tuned to match the global galaxy luminosity function combined with the assumption that the satellite galaxies do not suffer significant tidal stripping, even though their surrounding dark matter haloes can be removed through this process. Combining our results with measurements of the intracluster light should provide a way to inform theoretical models on the efficacy of the tidal stripping and merging processes.