A new method based on linear response theory is proposed for the determination of the KohnSham potential corresponding to a given electron density. The method is very precise and aords a comparison between Kohn-Sham potentials calculated from correlated reference densities expressed in Slater-(STO) and Gaussian-type orbitals (GTO). In the latter case the KS potential exhibits large oscillations that are not present in the exact potential. These oscillations are related to similar oscillations in the local error function d i r h À e i u i r when SCF orbitals (either KohnSham or Hartree-Fock) are expressed in terms of Gaussian basis functions. Even when using very large Gaussian basis sets, the oscillations are such that extreme care has to be exercised in order to distinguish genuine characteristics of the KS potential, such as intershell peaks in atoms, from the spurious oscillations. For a density expressed in GTOs, the Laplacian of the density will exhibit similar spurious oscillations. A previously proposed iterative local updating method for generating the Kohn-Sham potential is evaluated by comparison with the present accurate scheme. For a density expressed in GTOs, it is found to yield a smooth`a verage'' potential after a limited number of cycles. The oscillations that are peculiar to the GTO density are constructed in a slow process requiring very many cycles.