DISCLAIMER : Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility.If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.


Difference between /etc/hosts and /etc/resolv.conf

/etc/resolv.conf specifies the nameservers for resolver lookups, where it will actual use the DNS protocol for resolving the hostnames.
Typically the /etc/hosts file is used for administrative purposes such as backend and internal functions, which is substantially more isolated in scope, as only the local server will reference it it.

/etc/nsswitch.conf
specifies the lookup order with the hosts entry.

If this does not answer your question, please clarify further.

Look at the following manpages:

/etc/resolv.conf
specifies nameservers in order of search preference.
/etc/hosts overrides all nameservers by mapping urls/shortnames to IPs.