HalfofTheHalfofThe
  • Home
  • Technology
    • Reviews
    • Amazon
    • Apple
    • Cars
    • Facebook
    • Google
    • Mobile
    • Samsung
    • Tesla
    • Twitter
  • News
    • Sports
    • Amazon
    • Apple
    • Business
    • Cars
    • Entertainment
    • Facebook
    • Mobile
    • Samsung
    • Science
    • Tesla
    • Twitter
  • How To
    • Amazon
    • Apple
    • Cars
    • Facebook
    • Games
    • Google
    • Mobile
    • Samsung
    • Science
    • Tesla
    • Twitter
  • Business
  • Entertainment
  • Health
    • Pets
    • What
    • Why
  • Lifehacks
    • Explain
    • SmartHome
    • SocialMedia
  • More
    • Amazon
    • Apple
    • Cars
    • Facebook
    • Google
    • Mobile
    • Netflix
    • Twitter
    • Samsung
    • Tesla
Search
Technology
  • How To
  • Explain
  • Mobile
  • Lifehacks
  • News
  • Reviews
  • SmartHome
  • Technology
Information
  • About Us
  • Contact Us
  • Cookie Policy
  • Privacy Policy
  • Terms and Conditions
All content
  • Home
  • Technology
    • Reviews
    • Amazon
    • Apple
    • Cars
    • Facebook
    • Google
    • Mobile
    • Samsung
    • Tesla
    • Twitter
  • News
    • Sports
    • Amazon
    • Apple
    • Business
    • Cars
    • Entertainment
    • Facebook
    • Mobile
    • Samsung
    • Science
    • Tesla
    • Twitter
  • How To
    • Amazon
    • Apple
    • Cars
    • Facebook
    • Games
    • Google
    • Mobile
    • Samsung
    • Science
    • Tesla
    • Twitter
  • Business
  • Entertainment
  • Health
    • Pets
    • What
    • Why
  • Lifehacks
    • Explain
    • SmartHome
    • SocialMedia
  • More
    • Amazon
    • Apple
    • Cars
    • Facebook
    • Google
    • Mobile
    • Netflix
    • Twitter
    • Samsung
    • Tesla
  • About Us
  • Contact Us
  • Cookie Policy
  • Privacy Policy
  • Terms and Conditions
2022. All Rights Reserved by Halfofthe. “As an Amazon Associate we earn from qualifying purchases.”
Notification Show More
Latest News
What We Know So Far About Season Two of The Last Of Us
What We Know So Far About Season 02 of The Last Of Us
Entertainment
As a small company Why we don't want to use Google apps or services
As a small company Why we don’t want to use Google apps or services
Google
Breaking Down the Samsung Galaxy S23 Price Increase in Europe and Australia
Breaking Down the Samsung Galaxy S23 Price Increase in Europe and Australia
Samsung
Samsung's Galaxy S23 Ultra May Get Selfie Camera Upgrades
Samsung’s Galaxy S23 Ultra May Get Selfie Camera Upgrades
News Samsung
WhatsApp is Improving Image Quality with New Feature
WhatsApp is Improving Image Quality with New Feature
News
Aa
HalfofTheHalfofThe
Aa
  • How To
  • Explain
  • Mobile
  • Lifehacks
  • News
  • Reviews
  • SmartHome
  • Technology
Search
  • Home
  • Technology
    • Reviews
    • Amazon
    • Apple
    • Cars
    • Facebook
    • Google
    • Mobile
    • Samsung
    • Tesla
    • Twitter
  • News
    • Sports
    • Amazon
    • Apple
    • Business
    • Cars
    • Entertainment
    • Facebook
    • Mobile
    • Samsung
    • Science
    • Tesla
    • Twitter
  • How To
    • Amazon
    • Apple
    • Cars
    • Facebook
    • Games
    • Google
    • Mobile
    • Samsung
    • Science
    • Tesla
    • Twitter
  • Business
  • Entertainment
  • Health
    • Pets
    • What
    • Why
  • Lifehacks
    • Explain
    • SmartHome
    • SocialMedia
  • More
    • Amazon
    • Apple
    • Cars
    • Facebook
    • Google
    • Mobile
    • Netflix
    • Twitter
    • Samsung
    • Tesla
Follow US
  • About Us
  • Contact Us
  • Cookie Policy
  • Privacy Policy
  • Terms and Conditions
2022. All Rights Reserved by Halfofthe. “As an Amazon Associate we earn from qualifying purchases.”
HalfofThe > Blog > How To > How To Edit Your Hosts File on Windows, Mac, or Linux?  
How To

How To Edit Your Hosts File on Windows, Mac, or Linux?  

Bippin
Last updated: 2022/06/14 at 9:06 AM
By Bippin Published April 7, 2022
Share
8 Min Read
How To Edit Your Hosts File on Windows, Mac, or Linux?  

On occasion, there might arise a need for you to edit the hosts file on your device. Sometimes the reason may be due to an attack or a prank, some other times it might be because you want to simply as well as freely control access to websites and network traffic.  

What you'll learn today
What is the use of host file?  What does hosts file contain?  How to Edit Hosts files for Windows 8/8.1 as well as 10?  How to edit Hosts files for Windows 7?  How to edit Hosts files for Ubuntu?  How to edit Hosts files for macOS (Any Version)?  The Finishing Notes  
How To Edit Your Hosts File on Windows, Mac, or Linux?  
How To Edit Your Hosts File on Windows, Mac, or Linux?  

What is the use of host file?  

Host files is used to convert a request by name to a numeric IP address either on the local network or the Internet. HOSTS files are used to override the DNS system, that is for testing purposes so that a Web browser or any other application can be redirected to a specific IP address.  

Hosts files are being used since ARPANET. These were used before DNS to resolve hosts names. Hosts files would be massive documents used to aid the network name resolution.  

What does hosts file contain?  

The hosts. Txt file is a plain-text file that accommodates a list of host names along with their corresponding IP addresses.  

Microsoft had kept the hosts file alive in Windows networking which is the reason why it varies very little whether used in Windows, macOS, or Linux devices. The syntax is mostly the same across all of the mentioned platforms. The majority of the hosts files will have several entries for loopback. We can use that as the basic example for the quintessential syntax.  

The first part contains the location to redirect the address. The second part contains the address that you will want to redirect. The third part is the comment. These can be separated using a space, however, for ease of reading, they are typically separated by either one or two tabs.  

127.0.0.1 localhosts #loopback  

Now let’s take a look at how you can access the hosts files in the different operating systems…  

How to Edit Hosts files for Windows 8/8.1 as well as 10?  

Unfortunately, if you are using Windows 8 or 10, they make it annoying to open apps as administrator. However, it is not too difficult. To begin the search for Notepad, then right-click on Notepad in the search results list, then click on the option that says to run it as administrator. If you are using Windows 10 this can be found in the Start Menu.  

After you have done as stated above, open up the following file using the File -> Open feature.  

c:\windows\system32\drivers\etc\hosts  

Here you can edit host files as normal.  

How to edit Hosts files for Windows 7?  

If you want to access the hosts file in Windows 7 you have the ability to do so by using the following command in the Run Line to open notepad and the file.  

notepad c:\windows\system32\drivers\etc\hosts  

After the notepad is open you can edit the file. In this article, we will be blocking Facebook as an example. To do this just enter the following after the # mark.  

0.0.0.0    www.facebook.com  

Now that you have edited the Hosts file remember to save it.  

After we make the above change notice that if we try to access Facebook in IE we cannot get to the page. 

We also were not able to get to Facebook even in Google Chrome. (For further information check notes at the end).   

How to edit Hosts files for Ubuntu?  

In Ubuntu 10.04 as well as most Linux distro’s you have the ability to edit the hosts file directly in the terminal. You can also use your favorite editor, or you could just whip open your favorite GUI text editor. For this article, we will be using VIM. Like in Windows 7, Ubuntu’s hosts file is located in the /etc/ folder. Though here it is at the root of the drive. In order to be able to edit this file, you will have to open it as root, that is the reason why we use sudo here.  

After it is opened, we can then edit it to redirect Facebook into nothing. You will notice that while operating with Ubuntu there is also a section for IP6. For most requirements you will only have to edit in the top section, then ignore the IP6.  

After we are done, we can save the file, then try to visit Facebook.com. Just like in windows we will be able to see that we are redirected to a site that does not exist.  

How to edit Hosts files for macOS (Any Version)?  

In macOS, the process of accessing the hosts file is similar to Ubuntu. You have to begin in the terminal, then use your favorite editor, if you wish to you can even call a GUI text editor, however, it is easier to do so using the terminal.  

The file will look a bit more like Windows, the only difference being that this has a little less explanation. Again, we will be going to redirect Facebook.  

This time it seems that 0.0.0.0 is a loopback, this will direct you to the computer’s Apache test page.  

The Finishing Notes  

There are a few things to note from this walkthrough that we did notice. When we tested after blocking Facebook, Chrome did not use the hosts file in any operating system, however, we were able to block Facebook in Chrome thanks to us adding www.facebook.com. Also, make sure you place an extra line after the last entry for the section.  

This should get you started in understanding the Hosts file as well as how it has the ability to help protect your computer. You also have the ability to use it to block sites that you don’t want a PC to be able to access. If you are having any more suggestions for any of the operating systems covered in this article, then leave a comment down below.  

If you liked this article (or if it helped at all), leave a comment below or share it with friends, so they can also know How to Edit Your Hosts File on Windows, Mac, or Linux. 

You Might Also Like

How to Reset Android Phone when Locked?

How to Share Location on Android?

How to Transfer Data from Android to Android?

How to Retrieve Deleted Text Messages on Android?

How to Facetime Android?

TAGGED: edit hosts files, hosts files
Share this Article
Facebook Twitter Pinterest Whatsapp Whatsapp Reddit Telegram Email Copy Link Print
Avatar photo
By Bippin
Aah, I see you’re here now, looks like I finally managed to capture your attention. If you’ve come all the way here then why don’t you follow my social accounts, so that you can be on this journey with me? Say what?
Previous Article How to Remove a Password from a PDF File?  How To Remove a Password from a PDF File? The 2 best ways
Next Article 10 Kitchen Items You Wish you Knew Earlier: Best of Amazon 10 Must-Have Kitchen Products You Wish you Knew Earlier: Best of Amazon
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Trending

Learn how to use the Microsoft word document
Learn how to use the Microsoft word document
Explain Microsoft
A few details regarding the upcoming Google Pixel 7 as well as the Pixel 7 Pro
A few details regarding the upcoming Google Pixel 7 as well as the Pixel 7 Pro 
Google
Apple M1 VS M2 Comparison - Features and Specs
Apple M1 VS M2 Comparison – Features and Specs
Apple Mac
How to Electronically Sign PDF Documents Without Printing and Scanning Them? Easy guide
Life How To
What Is r/Place? How to use it on Reddit? Everything Explained about rPlace
What Is r/Place? How to use it on Reddit? Everything Explained about rPlace
Lifehacks How To SocialMedia
How to View Blurred Text on Websites?
How to View Blurred Text on Websites?
How To

People Also Ask For

How to Reset Android Phone when Locked?
Android

How to Reset Android Phone when Locked?

Bippin Bippin January 22, 2023
How to Share Location on Android?
Android

How to Share Location on Android?

Bippin Bippin January 22, 2023
How to Transfer Data from Android to Android?
How To

How to Transfer Data from Android to Android?

Bippin Bippin January 19, 2023
How to Retrieve Deleted Text Messages on Android?
How To

How to Retrieve Deleted Text Messages on Android?

Bippin Bippin January 19, 2023
How to Facetime Android?
How To

How to Facetime Android?

Bippin Bippin January 18, 2023
How to Empty Trash on Android?
Android

How to Empty Trash on Android?

Bippin Bippin January 16, 2023
How to SSH on Windows?
How To

How to SSH on Windows?

Bippin Bippin January 14, 2023
How to Upgrade to Windows 10?
How To

How to Upgrade to Windows 10?

Bippin Bippin January 14, 2023
How to Install Windows 11?
How To

How to Install Windows 11?

Bippin Bippin January 13, 2023
How to Update to Windows 11?
How To

How to Update to Windows 11?

Bippin Bippin January 13, 2023
How to Install Windows?
How To

How to Install Windows?

Bippin Bippin January 11, 2023
What Windows do I Have?
How To

What Windows do I Have?

Bippin Bippin January 11, 2023
Show More
HalfofTheHalfofThe
Follow US

2023. All Rights Reserved by Halfofthe. “As an Amazon Associate we earn from qualifying purchases.”

  • About Us
  • Contact Us
  • Cookie Policy
  • Privacy Policy
  • Terms and Conditions

Removed from reading list

Undo
Welcome Back!

Sign in to your account

Lost your password?