Skip navigation

What is the difference between private/etc/hosts and etc/hosts?

1509 Views 20 Replies Latest reply: Feb 21, 2013 11:27 AM by ds store RSS
1 2 Previous Next
chungster Level 1 Level 1 (0 points)
Currently Being Moderated
Feb 20, 2013 5:38 AM

I was attempting to modify my iMac 'hosts' file in terminal and tried the usual sudo nano /private/etc/hosts. It would bring up an empty page. I thought the hosts file was simply empty. I added the entries I wanted to block and when I tried to exit and save (^o or ^x and choosing yes), i would get the error '/private/etc/hosts: No file exists' (or something to that effect).

After some researching, I tried using 'sudo nano /etc/hosts' and it brought up what looks like the hosts file (It has the same entries as I have on my MBP running the same OS when I sudo nano /private/etc/hosts)

Is there a difference in the file in /private/etc/hosts and /etc/hosts ?
Does that mean I have a problem with my iMacs' host file?

iMac, Mac OS X (10.6.8)
  • WZZZ Level 6 Level 6 (11,875 points)

    Don't undertstand that. /private/etc/hosts is the full path to /etc/hosts. What about just entering /private in Go to Folder, then hitting  /etc and then scrolling to and opening /hosts?

  • ds store Level 7 Level 7 (30,305 points)

    /etc folder is a alias that points to /private/etc

     

    Screen shot 2013-02-20 at 10.55.35 AM.jpg

     

     

    Use the free TextWrangler directly from Barebones, it's a lot easier editing this hosts file and copying/pasting than via Terminal.

     

     

    direct changes to /private/etc/hosts is likely restricted, thus the alias is likely used to keep security checks in the loop.

  • WZZZ Level 6 Level 6 (11,875 points)

    Hmmm, alias? Where do you see that?

     

    Screen shot 2013-02-20 at 11.18.58 AM.png

     

    Screen shot 2013-02-20 at 11.20.36 AM.png

  • BobHarris Level 6 Level 6 (12,480 points)

    Hmmm, alias? Where do you see that?

    Technically it is a file system "Symbolic Link" which is similar to a Mac OS X Finder Alias, but different.

     

    Symbolic Links are dereferenced by the file system drivers.  Aliases are dereferenced by code above the file system, so strict Unix command line commands cannot use an Alias to find a file.

     

    There are also file system "Hard Links" which are yet another similar to an Alias, but totally different.

     

    Each has its advantages, and their limitations.

  • WZZZ Level 6 Level 6 (11,875 points)

    But since it's a symlink (not to be confused with a Finder alias) to /private/etc, I still don't understand ds store's screenshot showing etc as an alias. Why is that showing as a Finder folder with the alias icon?

  • ds store Level 7 Level 7 (30,305 points)

    chungster wrote:


    I just tried the 'sudo nano /private/etc/hosts' via terminal and it brought up a list of entries (not a blank page like before).  I promise I wasn't on drugs last night, but somehow all seems ok!

     

    You were tired and mistyped, nano created a new file at that location is likley what occured.

     

     

     

    Hmmm, alias? Where do you see that?

     

    At   /   (root directory)

     

    There is a whole smathering of hidden files and folders there if you enable invisble things.

  • WZZZ Level 6 Level 6 (11,875 points)

    Hmmm, alias? Where do you see that?

     

    At   /   (root directory)

     

    That's exactly from where I took that screenshot (after toggling visibility), which does not show etc as an alias.

  • BobHarris Level 6 Level 6 (12,480 points)

    But since it's a symlink (not to be confused with a Finder alias) to /private/etc, I still don't understand ds store's screenshot showing etc as an alias. Why is that showing as a Finder folder with the alias icon?

    The Finder can see that it is a Symbolic Link, and since Aliases and Symlinks perform similar services, the Finder is being lazy and tagging both Aliases and Symbolic Links as "Alias".


    But /etc would not function as a Finder Alias, and really needs to be a Symbolic Link, as the various Mac OS X commands, utilities, daemons, etc... would fail if /etc was an Alias.

  • ds store Level 7 Level 7 (30,305 points)

    WZZZ wrote:

     

    That's exactly from where I took that screenshot (after toggling visibility), which does not show etc as an alias.

     

    Your screen shot only shows the open private folder

     

    Are you on 10.6? If not that might explain it.

     

    Use TextWranger > Open and Show Everything and Invisible thingies.

  • WZZZ Level 6 Level 6 (11,875 points)

    I AM showing all invisibles. That's where the Get Info for etc is coming from, which is showing etc without the alias symbol. No matter what I try it comes up without the alias. This is on 10.6. BobHarris is saying that it really shouldn't be showing as an alias, since it's a symlink.

     

    Maybe it's showing like that with TextWrangler on yours? I'll have to try TW later.

1 2 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.