What is the hosts file and when do you use it?
BeginnerConceptDNS
Answer
/etc/hosts maps names to IPs locally and is consulted before DNS. We use it to test a site on a new server before changing DNS, or to pin names in an emergency.
echo "203.0.113.10 app.example.com" | sudo tee -a /etc/hosts
curl --resolve app.example.com:443:203.0.113.10 https://app.example.com does the same for one command, without editing files.
More on DNS
What does DNS do and what happens when you type a URL into a browser?BeginnerWhat are the common DNS record types?BeginnerWhat is the difference between a recursive resolver and an authoritative server?IntermediateExplain the DNS resolution chain step by step with dig.IntermediateWhat is TTL in DNS and how does it affect changes?BeginnerWhat is negative caching in DNS?Intermediate