Free tools Windows power users keep installed
One-click scans. No signup required.
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
To configure Ubuntu’s /etc/hosts file, back it up, edit it as root, preserve the standard localhost entries, add each mapping as IP address canonical hostname aliases, save the file, and verify the result with getent or resolvectl. Entries are local static mappings; they do not create public DNS records or replace Ubuntu’s DNS resolver configuration.
What /etc/hosts does
Ubuntu’s /etc/hosts is a plain-text table that associates IP addresses with hostnames. When a program asks the operating system to resolve a name, the system name-service stack can consult this file and return the listed address without contacting a DNS server. This makes it useful for a small number of stable, local names: a file server on a home network, a test site on a development machine, or the computer’s own hostname.
A hosts-file entry is not a DNS-zone record. It affects the Ubuntu system on which the file is installed, not other computers, phones, containers, or users on the network. It also cannot provide DNS record types such as MX records. systemd-resolved’s documentation notes that mappings in /etc/hosts are resolved to their configured addresses, but they do not affect lookups for non-address types.
Before you edit the file
- Use an account that can run
sudo. - Know the exact IP address and hostname you want to map. Check spelling, capitalization, hyphens, and periods before saving.
- Plan a rollback. A backup lets you restore the previous file if a typo affects local name resolution.
- Use a root-aware editor command. Opening the file as an ordinary user and trying to save it later usually fails because
/etc/hostsis owned by root.
Ubuntu treats hostnames as names made from letters and numbers, hyphens, and periods, subject to the usual start-and-end rules documented by the hosts manual. Use a fully qualified name such as fileserver.example.test when that is the canonical name, and put a short alias such as fileserver on the same line if you want both forms to work.
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
Step-by-step: add a host mapping
1. Back up the current file
Run:
sudo cp /etc/hosts /etc/hosts.bak
The copy is stored at /etc/hosts.bak. It is a point-in-time backup, so make a new copy before a later major change if you want to preserve the current version too.
2. Open /etc/hosts with administrator rights
The safer interactive option is:
sudoedit /etc/hosts
sudoedit creates a temporary working copy, opens it in the editor configured for your account, and writes it back with the correct ownership after you save. If you prefer Nano, use:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
sudo nano /etc/hosts
In Nano, save with Ctrl+O, confirm the filename, and exit with Ctrl+X. Do not replace the file with a new empty document; start from the existing contents.
3. Keep Ubuntu’s standard entries
A typical Ubuntu file includes entries like these:
127.0.0.1 localhost
127.0.1.1 myhost.example.test myhost
192.168.1.10 fileserver.example.test fileserver
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
The exact local hostname and address may differ on your installation. The important defaults are the IPv4 localhost line, the IPv6 localhost line, and the multicast lines. Leave them intact unless you have a specific, documented reason to change them. Ubuntu commonly uses 127.0.1.1 for the machine’s own fully qualified hostname and its short name.
4. Add your mapping in the correct order
Each non-comment line follows this pattern:
IP_address canonical_hostname [aliases...]
Put the address first, followed by the canonical hostname, followed by zero or more aliases. Separate fields with spaces or tabs. Anything after a # is a comment and is ignored by the resolver.
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
For example, to map a server at 192.168.1.10:
192.168.1.10 fileserver.example.test fileserver
Both fileserver.example.test and fileserver can then resolve to 192.168.1.10 on this Ubuntu computer. An optional comment can document the purpose:
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →192.168.1.10 fileserver.example.test fileserver # office storage
Do not put the hostname before the address, split aliases across separate lines unnecessarily, or add punctuation to a name. If an address changes, update the existing line rather than leaving conflicting old and new entries in place.
5. Save, close, and check for obvious mistakes
After saving, display the file:
cat /etc/hosts
Check that every mapping has an address first, that the intended name appears after it, and that the standard localhost records remain present. To compare with your backup:
diff -u /etc/hosts.bak /etc/hosts
A clean, readable file is easier to troubleshoot than one containing duplicate entries, stale addresses, or unexplained overrides.
How to test a new entry
Test through the same system name-service mechanisms that applications normally use rather than relying only on a network utility.
Recommended Free Tools
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
Use getent for the system name-service stack
getent hosts fileserver
A successful result prints an address and the name (and possibly an alias). If there is no output, check the spelling, the address-first order, and whether the line was saved to /etc/hosts rather than to an editor’s temporary file.
Use resolvectl with systemd-resolved
resolvectl query fileserver.example.test
This asks the resolver service for the name and shows the address it selected. A hosts-file mapping is handled locally by systemd-resolved and is not sent to the network. The service also synthesizes localhost and localhost.localdomain as 127.0.0.1 and ::1.
Check reachability separately
ping -c 1 fileserver
A successful lookup does not prove that the host is reachable or that it accepts ICMP traffic. Conversely, a failed ping can be a firewall or service issue even when the hosts entry is correct. Use getent or resolvectl to separate name-resolution problems from network connectivity problems.
What a correct Ubuntu hosts file looks like
| Line | Purpose | Important detail |
|---|---|---|
127.0.0.1 localhost |
IPv4 loopback name | Keep this mapping for local services that use localhost. |
127.0.1.1 myhost.example.test myhost |
Local machine name | Ubuntu often places the computer’s FQDN and short name on this address. |
192.168.1.10 fileserver.example.test fileserver |
Custom local server mapping | Replace the example address and names with your actual values. |
::1 localhost ip6-localhost ip6-loopback |
IPv6 loopback names | Preserve the IPv6 localhost aliases unless you have a documented reason not to. |
ff02::1 ip6-allnodes |
IPv6 link-local multicast group | Standard Ubuntu entry; do not remove casually. |
ff02::2 ip6-allrouters |
IPv6 router multicast group | Standard Ubuntu entry; do not remove casually. |
Spacing is not significant as long as fields are separated by spaces or tabs. Keeping columns aligned is recommended because it makes reviews and future edits easier.
Changing Ubuntu’s hostname safely
If you are changing the computer’s hostname, update /etc/hosts as part of the same change. Put the new name on the 127.0.1.1 line before applying the hostname change. For example, a line could temporarily read:
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
127.0.1.1 ubuntu newname
Then apply the new system hostname using your normal hostname-management command, verify that /etc/hostname contains the intended name, and remove the old alias from the hosts line once the change is complete. The key requirement is consistency: the name in /etc/hostname and the local name represented in /etc/hosts should agree.
Afterward, open a new shell or log in again if a prompt still displays the previous name. Use hostname to see the active kernel hostname and getent hosts <name> to verify that the local name resolves.
/etc/hosts and systemd-resolved
Ubuntu’s resolver service reads local hosts mappings and answers them immediately. Because the answer is local, the name is not sent to an upstream DNS server. This is useful for private development names and internal addresses that should never be published externally.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteThe file is only one input to name resolution. It does not configure DNS servers, search domains, or link-specific resolver settings. Ubuntu Server documentation recommends using resolvectl and systemd-resolved for resolver configuration instead of manually replacing /etc/resolv.conf. Editing /etc/hosts cannot fix an incorrectly configured DNS server, and changing DNS settings cannot substitute for a missing local hosts entry when you need a static override.
On systems where systemd-resolved is in use, its hosts-file support can be disabled with ReadEtcHosts=no. If that setting is present, entries in /etc/hosts will not be consulted by the service; check the resolver configuration before treating a valid-looking line as ineffective. Do not disable this support unless you understand which other component will provide local hostname mappings.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
Troubleshooting common failures
sudo says it cannot resolve the host
This message usually means the system’s current hostname does not resolve through the local configuration. Check both files:
hostname
cat /etc/hostname
cat /etc/hosts
Make sure the active hostname, including capitalization and punctuation, appears on the local machine’s 127.0.1.1 line or another appropriate local mapping. Correct the spelling, save the file, and run the command again. Keep /etc/hostname and /etc/hosts synchronized after renaming the machine.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesgetent hosts name returns nothing
- Confirm that the file was saved as
/etc/hosts, not as/etc/hosts.txtor an editor backup. - Check that the address is first and the hostname follows it.
- Check every character in the requested name, including hyphens, periods, and capitalization.
- Remove or correct duplicate lines that contain an obsolete address.
- If systemd-resolved is active, run
resolvectl query nameand inspect its result separately.
The name resolves, but one application still fails
Hosts-file changes normally take effect immediately, so a reboot is not normally required. An individual application may retain its own DNS result, however. Close and reopen that application, restart the service that performs the lookup, or follow that application’s documented cache procedure. If getent and resolvectl return the expected address while one program does not, the remaining problem is likely in that program’s cache or resolver behavior rather than in the hosts entry.
The address is correct, but connections still fail
Name resolution and connectivity are separate. First confirm the address returned by getent. Then verify that the destination is powered on, reachable from the current network, listening on the required port, and not blocked by a firewall. A hosts file cannot create a route, start a service, or bypass access controls.
IPv4 works but IPv6 behaves unexpectedly
Check whether the application is choosing the IPv6 result from a separate ::1 or other IPv6 entry. Preserve the standard IPv6 localhost mappings unless you have a specific design requirement. Test the exact name and address family used by the application rather than assuming that an IPv4 result describes IPv6 behavior.
Restore the backup if necessary
If an edit breaks local resolution, restore the known-good copy:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →sudo cp /etc/hosts.bak /etc/hosts
Then verify the restored contents and rerun:
getent hosts localhost
getent hosts <your-hostname>
Replace the angle-bracketed placeholder with the real hostname; do not type the brackets. Once the system is working, create a fresh backup before attempting a corrected edit.
Operational practices for reliable hosts files
- Keep one authoritative line for each name and update the address in place.
- Use the canonical fully qualified hostname first, followed by short aliases.
- Add a brief comment for temporary development or lab mappings, including why the entry exists.
- Remove entries when a server is retired or its address changes; stale local overrides can be harder to notice than a normal DNS failure.
- Review the file after network migrations, hostname changes, and system restorations.
- Limit edits to administrators. A malicious hosts-file change can redirect software to an unintended local address.
Quick command reference
| Task | Command |
|---|---|
| Create a backup | sudo cp /etc/hosts /etc/hosts.bak |
| Edit with the configured editor | sudoedit /etc/hosts |
| Edit directly in Nano | sudo nano /etc/hosts |
| Show the file | cat /etc/hosts |
| Compare with the backup | diff -u /etc/hosts.bak /etc/hosts |
| Test the system name-service stack | getent hosts name |
| Query systemd-resolved | resolvectl query name |
| Test one ICMP packet | ping -c 1 name |
| Restore the backup | sudo cp /etc/hosts.bak /etc/hosts |
Replace name with the hostname you are testing. A successful getent or resolvectl result confirms resolution; it does not by itself confirm that the remote service is available.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

