How to Block the Access to Certain Websites on Linux

Code With Arjun
Oct 27, 2021
Block certain websites on Linux

By:Arjun Gautam

We can block the access to certain websites on linux as shown in picture below , facebook.com is refused to connect while youtube.com is opening in other tab.

Blocking access to Facebook

Step : 1

Open /etc/hosts in text editor (gedit in my case) with sudo privilege as show in below diagram .

Opening hosts in gedit

Step 2 :

You will get the text editor like this :

Text editor file to add websites

Step 3 :

Now add websites you want to block using

127.0.0.1 www.facebook.com

127.0.0.1 www.p*rnhub.com and so on .

Step 4 :

facebook ,p*rnhub blocked

Subscribe to my youtube channel for more programming related videos.

www.youtube.com/arjuncodes

--

--