3 ms·
I do this, although only by saying sudo cp hosts.play /etc/hosts or sudo cp hosts.work /etc/hosts It's simple, and surprisingly efficient.
by bajsejohannes 15y ago
I do this, although only by saying
sudo cp hosts.play /etc/hosts
or
sudo cp hosts.work /etc/hosts
It's simple, and surprisingly efficient.
- ianl 15y agoThe only problem with this method is that if you modify your hosts file, you have to modify both.
- StavrosK 15y agosudo cp /etc/hosts /etc/hosts.bak && cat hosts.work >> /etc/hosts sudo cp /etc/hosts.bak /etc/hosts Note: I just wrote this now with no testing whatsoever.
- pyre 15y agoJust create a Makefile or something that cats together hosts.common and hosts.work or hosts.play. all: cat hosts.common hosts.work.in > hosts.work cat hosts.common hosts.play.in > hosts.play Make common changes to hosts.common and easily build your final hosts files. play: cat hosts.play | sudo tee /etc/hosts > /dev/null work: cat hosts.work | sudo tee /etc/hosts > /dev/null
- macrael 15y agoHow often do you modify your hosts file? I only ever find myself adding more things to block to it.
- crocowhile 15y agoI did this in the past too. The amazing thing is that it actually cures the addiction, not just the symptoms. On the first day you find yourself clicking on the reddit bookmark like an idiot every 20 mins, only to be redirected to localhost. After a few days the impulse is gone and you can actually go back to a non censured /etc/hosts: your self control is back. YMMV.
- mvalle 15y agoDoes this work with Chrome? I believe Chrome does it's own dns resolution and skips the host file. (I defiantly know it won't resolve localhost if you're offline)
- pavel_lishin 15y agoI've edited my hosts file with various domain->ip mappings, and it's worked fine for me in chrome.
- sireat 15y agoWhen I am working on Linux I do the same thing, except I have cron job copy hosts.work to hosts at 9am(insert your favorite get to work time) and hosts.play at 5pm. Works really well. I wonder if one can do the same on Windows 7, some way of scheduling tasks easily.