Accidently I corrupted my nsswithch.conf file and now my hosts are not working. How can I restore or recreate it?

  • grep nsswitch.conf /var/lib/dpkg/info/*.postinst leads to /var/lib/dpkg/info/base-files.postinst and /var/lib/dpkg/info/libc-bin.postinst, which lead to /usr/share/libc-bin/nsswitch.conf and /usr/share/base-files/nsswitch.conf. The libc-bin post-installation script is more specific, so I'd use that.
    – muru
    Mar 23, 2017 at 5:52
  • @muru it may also be modified by the libnss-mdns postinst I think Mar 23, 2017 at 10:40
  • This question is not a question of that other question, because the solutions listed there do not work for /etc/nsswitch.conf. Indeed, dpkg -S /etc/nsswitch.conf does not return any results (on Artful).
    – Bram Geron
    Nov 1, 2017 at 16:34

1 Answer 1


This file is relatively generic, I would copy it from a working system of the same Ubuntu release

This should at least get you going - it's the default from xenial and should work regardless on pretty much any version.

# /etc/nsswitch.conf
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat
group:          compat
shadow:         compat
gshadow:        files

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files
netgroup:       nis

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.