As some sites like facebook are distracting to me, I have decited to edit /etc/hosts
file in order to block (temporarily) those sites as an extra way to avoid these sites. As an example, my hosts file is like below:
127.0.0.1 localhost
127.0.1.1 user
127.0.0.1 www.facebook.com
127.0.0.1 www.youtube.com
However, when I'm home, I want to have access to those websites, and therefore I comment out those websites manually by opening the file again, and commenting one by one all the websites as shown below:
127.0.0.1 localhost
127.0.1.1 user
#127.0.0.1 www.facebook.com
#127.0.0.1 www.youtube.com
How can I create a script that does exactly this job? Commenting out the websites that are included in the hosts file, and removing the comment when I want?