0

I made a mistake that resulted in the deletion of /etc/pam.d, how do I restore the PAM configuration to the state that would be generated for my currently installed packages when I don't know the specific files to restore?

1 Answers1

3

Use dpkg -S /etc/pam.d/* to find out which packages installed PAM files/services, then use apt to reinstall those packages and tell it to also install missing configuration files:

$ sudo apt install --reinstall -o Dpkg::Options::="--force-confmiss" $(dpkg -S /etc/pam.d/\* | cut -d ':' -f 1)

Thanks to @alvin-row for the bit on how to tell apt to install missing configuration files

  • 1
    The main pam config files, like common-password, etc are not connected with packages... – Gert van den Berg Sep 02 '22 at 15:15
  • Any tips for those cases, @GertvandenBerg? – Ross Patterson Jan 05 '23 at 06:05
  • 1
    pam-auth-update seems to be involved potentially (there are also some command that prompts about restoring the configs on some package updates, not sure which one that is now. (I mainly commented because that did not work for me) (I was mainly struggling with the common-* configs – Gert van den Berg Jan 05 '23 at 09:45