Is there a way to temporarily block websites in Ubuntu?
For example let's say ... Facebook (or any other website) is just available from 8pm or just for five minutes within e.g. two hours?
Thank you!
Is there a way to temporarily block websites in Ubuntu?
For example let's say ... Facebook (or any other website) is just available from 8pm or just for five minutes within e.g. two hours?
Thank you!
The tool I'd recommend is Get-Shit-Done. It edits your host file so that you cannot access blocked domains using any browser. However, it does not have a scheduler (although you could use
cron
for that).Stay Focusd is Chrome Extension that does something similar.
I personally use a secondary profile in Chrome, with the Whitelist extension, so that it blocks all websites, other than absolutely necessary ones
Open Terminal (CTRL+ALT+T).
Type
sudo -i
in the input field. Check the Run in terminal option. Finally click Run button.Type your password if necessary and press enter. Then do the following command.
You will get gedit Text Editor window.
For example, if we need to block Facebook just add the following lines just after
127.0.0.1 localhost
.By doing this, it will block the site in all browsers including Google Chrome, Chromium, Mozilla etc.... In fact, you can't access the website at all by any means.
That's it. When you now open www.facebook.com or facebook.com, you cannot access it. To enable back Facebook, remove the lines we added from the file
/etc/hosts
or as Eliah Kagan said you can add a # character before the 0.0.0.1 text we added in /etc/hosts to make it a comment and to block it again just remove # character from the beginning of the line.Example
Blocking :
Enabling It Back by making the line a comment :
Source
If you use Firefox, the LeechBlock add-on looks like it might do what you wish.
I think that this is important topic, so I've made python script to deal with issue https://gist.github.com/josifoski/3d1406bba37694e19fce9d1e032bcb99
Ubuntu 20.04
Open a terminal type
sudo nano /etc/hosts.deny
or with any editor in sudo privileges.Then add all the urls you want to block
Save the file and reopen your browser