trying to block websites with Terminal

Discussion in 'macOS' started by kmj2318, Nov 2, 2016.

  1. kmj2318 macrumors 68000

    kmj2318

    Joined:
    Aug 22, 2007
    Location:
    Naples, FL
    #1
    For some reason I can't get this to work after the Sierra update. Any body else?

    Btw, here's what I'm trying to do, just in case I'm making an error that someone can point out.

    [​IMG]
     
  2. JohnDS macrumors 65816

    Joined:
    Oct 25, 2015
    #2
  3. MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #3
    You have got to be joking does it even allow you to authenticate to edit a system file. Well to answer my own question after firing up my copy here it does not even allow you to open the /etc/hosts file even after allowing the hidden files which it is to supposedly be opened. To the OP I take it you have started the edit with sudo nano /etc/hosts?
     
  4. BrianBaughn macrumors 601

    BrianBaughn

    Joined:
    Feb 13, 2011
    Location:
    Baltimore, Maryland
    #4
    You can copy the "hosts" file, paste to the desktop, edit with TextEdit, Save, then copy/overwrite the file back to the /etc folder with authentication.
     
  5. ScoobyMcDoo macrumors 65816

    Joined:
    Nov 26, 2007
    Location:
    Austin, TX
    #5
    I saw in an article that you may need to use the command below to flush DNS cache after editing the the host file. Let us know if it helps.

    Code:
    dscacheutil -flushcache; sudo killall -HUP mDNSResponder
     
  6. KALLT, Nov 3, 2016
    Last edited: Nov 3, 2016

    KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #6
    Facebook enforces the ‘www’ sub-domain, so you have to include that. /etc/hosts does not resolve sub-domains, you have to be explicit. You also need to reboot to see the change (as the comment at the top implies).

    I hope you made a backup before editing this file.
     
  7. JohnDS macrumors 65816

    Joined:
    Oct 25, 2015
    #7
    @MacUser2525:

    I don't know why you are having problems opening the Hosts file with TextWrangler. I have been using it for years to edit my Host file with no problem.

    Just to double-check to make sure the newest version of TextWrangler hadn't changed anything, I download a fresh copy. I found it would open the hosts file after checking "show hidden files".

    In truth, that is not what I usually do. I usually pull down the Go menu in Finder and choose Go to Folder and then type /etc into the box. Then I navigate to the hosts file, right click and choose Open With, then Other, then TextWrangler.

    I am using El Capitan, so can't say if anything has changed on Sierra.

    Is the version of TextWrangler that you have one that was downloaded directly from Bare Bones Software as per my link above, or did you download it from the App Store? The App Store version is different and cannot be used to edit the hosts files: http://www.barebones.com/support/textwrangler/faqs.html

    Scooby is correct that the changes to the hosts file will not be effective until you clear the DNS cache or reboot.
     
  8. MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #8
    3.5.3 downloaded from their site ages ago on El Capitan I don't use the App store perhaps to old to have that capability. Most times I fail to see the point jumping through hoops to get something like this done as I always have a Terminal window open it is a simple Command Tab to switch to it. Then a quick bit of typing using again the Tab key auto completion for the file I need to edit and do in seconds, could probably do ten files or more in the time the fancy GUI method would take.
     
  9. JohnDS macrumors 65816

    Joined:
    Oct 25, 2015
    #9
    Current version of TextWrangler is 5.5.2. Not surprising yours didn't work.

    Many people prefer to use a GUI if it is available rather than memorize terminal commands.
     
  10. MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #10
    That and the scared of text factor I have no such fear when I started using these things before there even was personal computers there was nothing but that, now get off my lawn...
     

Share This Page