How To Edit & Modify HOSTS File in Linux

How to edit and modify the IP address hosts file on Linux systems.

When entering a website name, for example, in the address bar, the operating system will search in that file for the IP address to establish the connection.

Therefore all the changes we make in the hosts file will be analyzed first.

To know the web addresses that are currently registered in the hosts file, we go to the etc/hosts path:

sudo nano /etc/hosts

This will be the result:

How To Edit HOSTS File in Linux

We have seen that an editor is required to access the hosts file and know its contents, it is vital that we access it with administrative privileges since otherwise, we can not make any changes to it.

The syntax to use to prevent access to a website is as follows:     (website_url)

For example, if we want to block one of the sites where we spend more time, Facebook, we will use the following line:



But not only can we block websites, but we can also allow the redirection to our own servers by entering just the name of this, for example, in the hosts file we can create the following entry: Server_TheLinuxCode

In this way, in the browser, it will no longer be necessary to enter the IP address but the assigned name, and it will redirect us automatically.

We save the changes using the key combination Ctrl + O, and we left the editor using Ctrl + X.

The results of blocking, for example, a website are immediate:

This process applies to all Linux distros.

With this, we check what a file as simple as the host can do in the behavior of web accessibility

It might be interesting

Sony plans to add advertising to free video games on PlayStation

Sony Interactive Entertainment is developing a plan to place ads in games on PlayStation consoles. This was reported by the business publication Business Insider, citing its sources. Earlier it became known about a similar initiative of Microsoft.

How To Create USB Drive Compatible with Linux, Windows & Mac

How to format and create a USB drive or pen drive that is compatible with Windows 10, 8, 7 or Mac or Linux. A file system is a method and structure of data used by an operating system, called Windows, Linux or Mac OS, for reading media files such as disks, removable drives, etc.

The new major update of Windows 11 will be called 22H2

It is expected that in the fall of the U.S. corporation Microsoft will release a major update to the operating system Windows 11, which is currently being developed under the codename Sun Valley 2.

Dolby Axon Desktop Client Software

The new Dolby Axon Desktop Client Software brings for a great surround sound system. This adds up to the inclusion of chatting while you are gaming.