We use the conditional luminosity function \Phi ( L|M ) { d } L , which gives the number of galaxies with luminosities in the range L \pm { d } L / 2 that reside in a halo of mass M , to link the distribution of galaxies to that of dark matter haloes . Starting from the number density of dark matter haloes predicted by current models of structure formation , we seek the form of \Phi ( L|M ) that reproduces the galaxy luminosity function and the luminosity dependence of the galaxy clustering strength . We test the models of \Phi ( L|M ) by comparing the resulting mass-to-light ratios with constraints from the Tully-Fisher ( TF ) relation and from galaxy clusters . A comparison between model predictions and current observations yields a number of stringent constraints on both galaxy formation and cosmology . In particular , this method can break the degeneracy between \Omega _ { 0 } and the power-spectrum normalization \sigma _ { 8 } , inherent in current weak-lensing and cluster-abundance studies . For flat \Lambda CDM cosmogonies with \sigma _ { 8 } normalized by recent weak gravitational lensing observations , the best results are obtained for \Omega _ { 0 } \sim 0.3 ; \Omega _ { 0 } \lta 0.2 leads to too large galaxy correlation lengths , while \Omega _ { 0 } \gta 0.4 gives too high mass-to-light ratios to match the observed TF relation . The best-fit model for the \Lambda CDM concordance cosmology with \Omega _ { 0 } = 0.3 and \Omega _ { \Lambda } = 0.7 predicts mass-to-light ratios that are slightly too high to match the TF relation . We discuss a number of possible effects that might remedy this problem , such as small modifications of \sigma _ { 8 } and the Hubble parameter with respect to the concordance values , the assumption that the universe is dominated by warm dark matter , systematic errors in current observational data , and the existence of dark galaxies . We use the conditional luminosity function derived from the present data to predict several statistics about the distribution of galaxy light in the local Universe . We show that roughly 50 percent of all light is produced in haloes less massive than 2 \times 10 ^ { 12 } \msunh . We also derive the probability distribution P ( M|L ) { d } M that a galaxy of luminosity L resides in a halo with virial masses in the range M \pm { d } M / 2 .