Open Terminal by navigating to Applications->Accessories->Terminal
Use the following command to edit HOSTS file
sudo gedit /etc/hosts
Suppose you want to block YouTube and Facebook on Ubuntu. Just add the following two lines in file as shown in the screenshot and click save.
127.0.0.1 www.youtube.com
127.0.0.1 www.facebook.com
Restart your computer. Now you won't be able to access these websites, no matter whatever web browser you use