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.
Restart your computer. Now you won't be able to access these websites, no matter whatever web browser you use