How to Edit the Hosts File in Ubuntu How to Block Websites in Linux Using the /etc/hosts File

HomeOther ContentHow to Edit the Hosts File in Ubuntu How to Block Websites in Linux Using the /etc/hosts File
How to Edit the Hosts File in Ubuntu How to Block Websites in Linux Using the /etc/hosts File
How to Edit the Hosts File in Ubuntu How to Block Websites in Linux Using the /etc/hosts File
The Hosts file is used to resolve domain names without using the Domain Name System (DNS).

This means that whenever your computer tries to connect to the domain (for example) "www.facebook.com", it will not ask the DNS for its IP address and will instead consider 0.0.0.0 as the IP address of "www.facebook.com". facebook.com”.

127.0.0.1 is a special address, called a loopback IP address and if a public switch, router or gateway receives a packet addressed to the loopback IP address, it is required to drop the packet without saving the information.

We have therefore made the domain “www.facebook.com” inaccessible in our example.

Click the like button if you liked the video.

Steps to block domains and subdomains using hosts file:
1. Once your hosts file is open, enter a comment in your hosts file to organize your IP address mappings to host names.
2. To add a comment, make sure you are on a new line and type /"#/" followed by your comment details. The /"#/" symbol will tell your computer to ignore anything that comes after /"#/" on the same line
3. Then, still on a separate line, enter 0.0.0.0 and a space followed by your domain name or subdomain name (website address) to block.

For example:
#Block Facebook
0.0.0.0 www.facebook.com

4. In the above example, www.facebook.com (domain name) will be blocked by the hosts file. To save these entries, go to the top left corner to file, left-click on it and left-click Save.

5. Open your browser and navigate to the website URL you just added to your hosts file. The blocked website will now be inaccessible, which means it has been blocked successfully.

[Note] Ubuntu hosting file location:
//etc//hosts

———

Ubuntu tutorials: https://www.youtube.com/playlist?listPLnisUReSm0-n83AJMGEBASf5LWohKgxXt

Bash Shell Script Tutorial: https://youtube.com/playlist?listPLnisUReSm0-neF6F_OJcAQyFy_62XJ7bW

Install Android Studio on Ubuntu 22.04 LTS Android Studio on Ubuntu 22.04 LTS: https://youtu.be/hEdpm1PfvvM
Install Ubuntu on Windows 11 (WSL) Windows Subsystem for Linux with GUI support: https://youtu.be/NXJjutYp4x8
Reset forgotten Ubuntu Linux password on WSL Debian, Kali, Reset Linux password on WSL Windows 11: https://youtu.be/oeXuxqR60Ns
Install Vim text editor (Enhanced Vi) on Ubuntu Debian Linux: https://youtu.be/zr17y9YHopQ
Ubuntu 23.04 – Is it worth upgrading? Let's learn how to upgrade! : https://youtu.be/dj38ni4dOpA
Upgrade Ubuntu to Ubuntu 23.04 Lunar Lobster using the GUI using the GUI: https://youtu.be/Q0xF4wrfA90
Edit the Hosts file in Ubuntu How to block websites on Linux using the /etc/hosts file: https://youtu.be/z6RxqJzLaQY

———

More tutorials for VMWare Workstation Player:
https://www.youtube.com/playlist?listPLnisUReSm0-ms8q_fNgcRJKte3_HUoyqq

Install Microsoft Windows 11 on VMware Player: https://youtu.be/3HBSuoVOpt0
Make Windows 11 full screen in VMware Workstation Player: https://youtu.be/1XaPXGYMwTo

Install macOS 12 Monterey on VMware Player: https://youtu.be/WLMTAqZ_3xU
Install VMware Tools and create macOS 12 Monterey in full screen: https://youtu.be/pF4mwgiYIaY
Fix no internet connection in macOS 12 Monterey on VMware Player: https://youtu.be/S7yRdl-kAAg

Install macOS 13 Ventura on VMware Player: https://youtu.be/CeSqdrf1WOg
Install VMware Tools and create macOS 13 Ventura in full screen: https://youtu.be/WQdGIRFL8qw
Fix no internet connection in macOS 13 Ventura in VMware Player: https://youtu.be/i-DDDDiAmPw

Install Ubuntu 22.04 LTS on VMware Player: https://youtu.be/LvYaZMV-ZlY
Create a manual snapshot in VMware Player: https://youtu.be/QOTJbtyu0XQ

Install Ubuntu 23.04 on VMware Workstation Player on Windows 11: https://youtu.be/St4UOkJVlMU

VMware Workstation/Pro very slow on Windows 11 22H2 – VMware Technology Network VMTN
https://youtu.be/2cG7Cew_41A

———

More tutorials on macOS:
https://www.youtube.com/playlist?listPLnisUReSm0-mldjmZ0SOoyLc4fLlrNeTj

Download and install NodeJS, HomeBrew (Package Manager) and N (Version Manager) on macOS: https://youtu.be/O6MKC5TgQao

Install Oracle Java JDK and OpenJDK on macOS 13 Ventura: https://youtu.be/F5HTPakOdi4

———

My equipment:
MSI GL65 Leopard Gaming Laptop
Intel Core i7-10750H 2.6 GHz, 10th Gen (6-core)
15.6/" FHD (1920*1080), IPS level 144 Hz
16 GB DDR4 RAM, 2666 MHz
Nvidia GeForce RTX 2060, 6 GB GDDR6
256GB NVMe M.2 SSD, 1TB 7200RPM SATA HDD
Windows 11 Home, 64-bit
HD webcam (720p at 30 fps)
SteelSeries RGB per-key keyboard

#Ubuntu #Linux #tanztalkstech2 #tanzTalkstech #tanzeelosama @tanzTalks.tech2 @tanzTalkstech @TanzeelOAnsari

Please take the opportunity to connect and share this video with your friends and family if you find it useful.

No Comments

Leave a Reply

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