Introduction
If you are new to Linux or DevOps, you might think DNS (domain name system) is something only big servers or cloud services handle. But there is a simple file on your computer that helps your system know which IP address matches a website name or server name.
That file is called /etc/hosts. It’s small but very important!
What is /etc/hosts?
/etc/hosts is a text file on your computer that connects names to IP addresses.
For example:
127.0.0.1 localhost
192.168.1.10 myserver.local
This means your computer knows:
• localhost is your own computer (IP 127.0.0.1)
• myserver.local is at IP address 192.168.1.10
Why Should You Care?
Here are some easy reasons why /etc/hosts is useful for beginners learning DevOps:
- Test websites or services locally You can pretend that a website or server is at a specific address on your own computer.
Example: 127.0.0.1 mytestsite.local
Now if you open a browser and go to mytestsite.local, your computer looks for it on your own machine.
Fix name problems quickly
If your internet’s DNS server has issues, your system won’t find websites by name. Using /etc/hosts, you can tell your computer where to find important servers without relying on the internet.Redirect websites for testing
Say you want to see how your app works if it connects to a different server. You can change /etc/hosts to make the name point somewhere else, like a test server.
How to Edit /etc/hosts?
• You need admin rights (use sudo on Linux)
• Open the file with a text editor, for example:
sudo nano /etc/hosts
• Add or change lines like:
127.0.0.1 mylocalapp.local
• Save and exit the editor.
Important Tips
• This file only works on your computer — it won’t affect other machines.
• Be careful while editing; a wrong entry can cause connection problems.
• Always backup before making big changes:
sudo cp /etc/hosts /etc/hosts.backup
Conclusion
Even though it’s simple, /etc/hosts is one of the most powerful tools in your DevOps toolbox. It helps you understand how computers find each other on a network — a very important concept for anyone working with servers, cloud, or containers.
Top comments (0)