Sometimes you need to block out distractions for a set amount of time. One of these is social networking, and it’s fairly early to temporarily break it (all for productivity of course!).
Mac or Linux users can prevent themselves from accessing example.com
like this:
|
|
This tells the computer that it hosts example.com
, so it won’t load it from the internet.
And to compliment this, we have sed
, which can delete lines from a file in-place based on a pattern:
|
|
Replace example.com
above with your social network of choice, and have a shot. It will take a few minutes to have an effect, because of open connections and your computer’s DNS cache.
Scheduling it in
Cron is the go-to solution for scheduling any command on Unix. We’ll run this as root
, as normal users don’t have permission to edit /etc/hosts
:
|
|
If prompted, select nano
as an editor.
If, for example, 6pm - 8pm weekdays is a distraction-free time for you, you would schedule the first command for 18:00 on days 1-5, and the second for 20:00 on days 1-5:
|
|
If you need something more advanced, consider learning how to use squid to manage web traffic.
When you break something …
If you accidentally delete your /etc/hosts
while experimenting, you can fetch its contents from /var/lib/dpkg/info/netbase.postinst
(source).