

You’ll need to enter your password before the command will execute. Open up a Terminal, then enter: sudo vim /etc/hosts You’ll need to launch Vim prefaced by sudo, which is conceptually and functionally similar to “Run as Administrator” on Windows operating systems. RELATED: Define a Great Vim Profile Using. The hosts file is protected, and your regular user account will not be able to edit it. Like Windows, Ubuntu’s hosts file is located in the /etc/ folder, though here it is in the root of the drive.

For this example we will use Vim, since it is one of the traditional text editors in Linux. You can use your favorite command-line editor or your favorite GUI text editor. In Ubuntu (and most Linux distributions) you can edit the hosts file directly in the Terminal. Also for more info on editing your Hosts file, check out The Geek’s article on how to create a shortcut to quickly edit your Hosts file. We also were not able to get to it in Google Chrome… (check notes at the end). We can use that for the basic example for the typical syntax.

Most hosts files will have several entries for loopback. The syntax stays mostly the same across all platforms. Microsoft, Apple, and other operating system developers have kept the hosts file around, which is why it varies very little between Windows, macOS, and Linux. Since they were used to aide in network name resolution, hosts files grew to become massive documents. The hosts files were used to resolve host names for decades before the DNS system was implemented. Alternatively, you may just want to control access to certain websites or control network traffic.Ĭomputers have had hosts files since the ARPANET days. Your host file might have been edited maliciously in an attack, or as a prank. Occasionally you may need to edit the hosts file on your machine. On Mac and Linux, edit the /etc/hosts file using your text editor as choice-be sure to launch it with sudo.

Open the hosts file, which is located under C:WindowsSystem32driversetc. On Windows, launch Notepad (or another text editor) as Administrator.
