I'm interested in being able to temporarily prevent myself from editing my /etc/hosts file for the sake of productivity. When I am trying to get work done, I like to block access to the websites that are the biggest timesuck for me and I generally choose to do so through the /etc/hosts file.
I was hoping to be able to write a script that I can run when I need something like an hour or two of purer productivity. From what I know about all of this stuff (and that isn't a great deal), it seems like the ideal script would be capable of going into my /etc/hosts file and blocking the sites I don't want access to. Then ideally it would somehow lock that file and prevent me from accessing it. Then at the end of the predetermined time period, maybe a cron job would unlike the sites again.
Any ideas on the best way to handle this? Specifically with regards to preventing my own access to the file for a predetermined period of time.