Crashes, 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 minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11To configure Ubuntu’s /etc/hosts file, back it up, edit it with root privileges, preserve the existing localhost entries, add each mapping as IP_address canonical_hostname [aliases...], then verify the result with getent or resolvectl. Changes normally take effect immediately, although an individual application can continue using a cached answer.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
What /etc/hosts does
/etc/hosts is a local text table that associates IP addresses with hostnames. It is useful when one Ubuntu computer needs a fixed name for another machine, when a local development service should be reachable by a memorable name, or when the computer’s own hostname must resolve consistently. It is not a DNS-zone editor and it does not configure the DNS servers used for names that are not listed locally.
As an Amazon Associate I earn from qualifying purchases.
Recommended Free Tools
Each active entry puts the address first, the canonical hostname second, and any aliases after that. Spaces or tabs separate the fields. A # starts a comment, so text after it on the same line is ignored. Hostnames can contain letters, numbers, hyphens and periods, subject to the start-and-end rules documented by the Ubuntu hosts(5) manual.
Before editing: understand the files involved
/etc/hosts versus /etc/hostname
/etc/hosts maps names to addresses. /etc/hostname stores the local system hostname. They serve different purposes, but the local name should be represented consistently in both files. If you are changing the machine’s hostname, update the appropriate 127.0.1.1 entry before applying the new hostname, then remove the obsolete alias after the change.
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
/etc/hosts versus DNS and /etc/resolv.conf
A hosts-file entry is a static answer on this computer. It does not publish a name to your LAN or to the internet, and it cannot provide DNS record types such as MX. Ubuntu Server guidance treats static hostnames as local /etc/hosts entries and recommends using resolvectl and systemd-resolved for resolver configuration instead of manually replacing /etc/resolv.conf.
What systemd-resolved does with the file
When systemd-resolved is active, it reads the hosts mappings locally and answers them without sending those names to the network. Its documentation notes that localhost and localhost.localdomain are synthesized as 127.0.0.1 and ::1. Hosts-file processing can be disabled with ReadEtcHosts=no; if that setting is in use, entries in the file will not be consulted by systemd-resolved.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Back up the current file
Create a copy before making any change. The backup command preserves the original file in the same directory:
sudo cp /etc/hosts /etc/hosts.bak
The command should return to the shell without an error. If you later need to undo the edit, compare the files first and restore the backup only when you are certain it is the correct version for this machine:
sudo cp /etc/hosts.bak /etc/hosts
Restoring a backup replaces the current file, so do not use the restore command as a first diagnostic step. Inspect the current contents and keep a copy of any deliberate entries you still need.
Edit /etc/hosts safely
Use sudoedit
The preferred interactive method is:
sudoedit /etc/hosts
sudoedit opens a temporary working copy in the configured editor and writes the result back with root privileges. Save the file and exit the editor normally. If no editor is configured, use the direct Nano command below.
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 →Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
Use Nano directly
sudo nano /etc/hosts
In Nano, save with Ctrl+O, confirm the filename, and exit with Ctrl+X. The command prompt may ask for your password because writing under /etc requires administrative privileges.
Do not replace the file with a partial template
Start from the existing contents. Ubuntu installations commonly include IPv4 localhost, a local-name line, IPv6 localhost, and IPv6 multicast entries. Deleting those lines can break programs that expect standard localhost names or prevent the local hostname from resolving as intended.
What an Ubuntu hosts file should look like
A typical file has entries similar to 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
| Line | Purpose |
|---|---|
127.0.0.1 localhost |
IPv4 loopback name. Keep this standard mapping unless you have a documented reason to change it. |
127.0.1.1 myhost.example.test myhost |
Common Ubuntu convention for the computer’s fully qualified name and its short alias. |
192.168.1.10 fileserver.example.test fileserver |
Example static mapping for another host on the local network; replace the address and names with your actual values. |
::1 localhost ip6-localhost ip6-loopback |
IPv6 loopback names. |
ff02::1 ip6-allnodes and ff02::2 ip6-allrouters |
IPv6 multicast names commonly present in Ubuntu’s example. |
The first two fields are not interchangeable: placing a hostname before an address makes the line invalid for hosts-file lookup. Keep aliases on the same line as the canonical name, separated by spaces or tabs.
Add a mapping for another machine
- Determine the address that should be used. For the example below, the server address is
192.168.1.10. - Choose one canonical hostname and, if useful, one or more short aliases. The canonical name appears immediately after the address.
- Add a line to
/etc/hosts:
192.168.1.10 fileserver.example.test fileserver
- Save the file, then query the short alias and the fully qualified name:
getent hosts fileserver
resolvectl query fileserver.example.test
getent hosts exercises the system name-service stack. resolvectl query is especially useful when systemd-resolved is active. Both commands should show the address associated with the name. A successful lookup confirms that the name resolves; it does not prove that the remote computer is powered on or accepting connections.
Test actual reachability separately
To send one ICMP request using the name, run:
ping -c 1 fileserver
A successful name lookup followed by a failed ping usually points to reachability, firewall, routing or service availability rather than a hosts-file syntax problem. Conversely, an unknown-host error from getent or resolvectl means the name, address, spelling or resolver path needs attention first.
Change Ubuntu’s own hostname
Ubuntu commonly associates the local machine name with 127.0.1.1. Suppose the current line is:
Rank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
127.0.1.1 ubuntu ubuntu-old
To introduce newname, first place the new name on that line:
127.0.1.1 ubuntu newname
Apply the hostname change using the hostname procedure appropriate to your system, then remove the old alias when it is no longer needed:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problems127.0.1.1 newname
The important requirement is consistency: the name reported by the system and the name associated with the local address in /etc/hosts should agree. Check both /etc/hostname and /etc/hosts for capitalization and spelling before restarting services or troubleshooting “cannot resolve my host” messages.
How lookup and caching affect the result
Hosts-file modifications normally take effect immediately. The file itself does not require a reboot. However, an application can cache a previous DNS answer or retain a failed lookup for a while. If getent and resolvectl return the new address but one program still uses the old one, close and reopen that program or restart only the affected service according to its own documentation.
systemd-resolved handles hosts entries locally and does not forward those names to configured DNS servers. This makes a hosts entry suitable for a private name that should resolve only on the Ubuntu machine. It also means that editing the file will not make the name available to other computers; each client would need its own entry or a shared DNS service.
Diagnose “sudo cannot resolve my host”
A warning such as “sudo: unable to resolve host …” usually means the current hostname does not match any local hosts-file name. Work through the checks in this order:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
- Read
/etc/hostnameand note the exact hostname, including capitalization and punctuation. - Open
/etc/hostsand check that the same name appears after an address, normally on the127.0.1.1line for the local machine. - Verify that the address comes first and that the hostname is not inside a comment beginning with
#. - Keep
127.0.0.1 localhostand the IPv6 localhost line intact unless a documented system design requires otherwise. - Run
getent hosts <name>, replacing<name>with the exact local hostname. - If systemd-resolved is active, run
resolvectl query <name>as a second check.
For example, if /etc/hostname contains newname, a matching hosts entry can be:
127.0.1.1 newname
If you need both a fully qualified name and a short name, list the fully qualified name first and the short form as an alias:
127.0.1.1 newname.example.test newname
After saving, run the lookup commands again. A reboot is not normally necessary; restart a particular application only if it continues to use stale data after the system resolver returns the corrected address.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Common mistakes and their fixes
Reversing the fields
Incorrect:
fileserver 192.168.1.10
Correct:
192.168.1.10 fileserver
Hosts-file syntax always starts with the IP address.
Using an alias on a separate line without an address
Every active line needs an address. Put related names on one line:
192.168.1.10 fileserver.example.test fileserver files
Editing without administrative privileges
A normal editor may open the file read-only or fail to save it. Use sudoedit /etc/hosts or sudo nano /etc/hosts from a user account allowed to use sudo.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
Accidentally commenting out a mapping
Anything after # is a comment. A line such as #192.168.1.10 fileserver does not create a mapping. Remove the leading # when the entry should be active.
Changing only one of the hostname files
If /etc/hostname says one name while /etc/hosts contains another, local commands and administrative tools can report resolution errors. Make the names consistent, then test with getent.
Expecting the mapping to work elsewhere
An entry is local to the computer where it was added. It does not update a router, DNS server or another Ubuntu installation. Configure those systems separately if the name must be shared.
Expecting mail or other DNS record types
The hosts file supplies address-to-name mappings. systemd-resolved’s documentation specifically notes that these mappings do not affect lookups for non-address types such as MX records. Use DNS for those records.
Use comments without hiding important entries
Comments are useful for recording why a static address exists, especially when an address may change. Keep the comment at the end of an active line:
192.168.1.10 fileserver.example.test fileserver # office storage host
Do not put explanatory text before the address unless the entire line is intentionally a comment. Keep comments factual and avoid recording passwords, tokens or other secrets in a world-readable system file.
A complete configure-and-verify workflow
- Back up the file with
sudo cp /etc/hosts /etc/hosts.bak. - Open it using
sudoedit /etc/hostsorsudo nano /etc/hosts. - Preserve the existing localhost and IPv6 lines.
- For each static name, add
IP_address canonical_hostname [aliases...]. - If changing the local hostname, make the
127.0.1.1entry and/etc/hostnameagree. - Save the file and run
getent hosts name. - When systemd-resolved is in use, run
resolvectl query name. - Use
ping -c 1 nameonly as a separate connectivity check. - If command-line lookups succeed but one application fails, restart that application rather than rebooting the computer.
When to use DNS instead
Use /etc/hosts for a small, deliberately local set of static mappings: a few lab machines, a temporary development name, or the Ubuntu computer’s own hostname. A centrally managed DNS service is more appropriate when many clients need the same names, addresses change regularly, reverse records must be maintained, or services need record types beyond address mappings. The hosts file is simple precisely because it is local and manual; that simplicity becomes a maintenance burden as the number of machines grows.
Final verification checklist
- The backup
/etc/hosts.bakexists. - Every active line begins with an IPv4 or IPv6 address.
- The canonical hostname follows the address, with aliases after it.
- Fields are separated by spaces or tabs, and comments begin with
#. 127.0.0.1 localhostand the IPv6 localhost mappings remain present unless intentionally redesigned.- The local hostname in
/etc/hostnamematches its entry in/etc/hosts. getent hosts namereturns the expected address.resolvectl query nameagrees when systemd-resolved is active.- An application that still shows old data has been restarted if necessary.
Once these checks pass, Ubuntu is using the intended local mappings, while ordinary names not listed in the file continue through the configured resolver path.
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.




