Linux Mint

How to Edit Hosts File on Linux Mint 21

Host file of Linux mint primarily maps the IP address with the domain names of the system thus making it useful for various purposes which include blocking a website and accessing any computer remotely. If you are unaware of how to edit a host file in your Linux Mint 21 and want to use it for multiple purposes, then read this guide.

What Is the Purpose of Hosts File in Linux Mint 21

Host file as mentioned above contains the IP addresses and hostname of the Linux system, but there are multiple uses of host file and those are:

  • Blocking any websites
  • Remotely accessing any Alias
  • Blocking advertisers and trackers
  • Testing an application
  • Adding or blocking specific networks

How to Edit the Hosts File in Linux Mint 21

The process of editing the host file of Linux Mint 21 is quite easy; open the host file on your Linux Mint 21 by using any terminal-based text editor, for example, nano:

$ sudo nano /etc/hosts

Now edit the host file by entering the data like IP addresses and host names for the connections you either want to block or access.

How to Block a Website through Hosts File

When it comes to security or parental control hosts file plays a crucial role as it can be used to block unwanted websites. The process of blocking a website is mentioned below:

$ <Website-URL>

For instance, if you want to block YouTube then use:


Next save the file and open the website on the browser of Linux Mint to see if the site is blocked or not:


Host files in an operating system generally contain the IP address and the domain name of that system, there are multiple uses of a host file which can be achieved by editing it and it can be done by stating its path with nano command.

About the author

Aaliyan Javaid

I am an electrical engineer and a technical blogger. My keen interest in embedded systems has led me to write and share my knowledge about them.