Deleting /etc/hosts Is it necessary?

Discussion in 'macOS' started by MrCheeto, Oct 8, 2010.

  1. MrCheeto macrumors 68030

    MrCheeto

    Joined:
    Nov 2, 2008
    #1
    I have been buying and selling macs, but I always use them as my personal computer for a while. In fact I currently own two PowerBook G4's and sold another several weeks ago.

    To remove all of my files and settings I simply delete the AppleSetupDone file, remove the entire User and subfolders then it starts up as a new computer.

    What I'm wondering is why one would need to delete /var/db/netinfo and is the Leopard and Snow Leopard equivalent /etc/hosts or what?
     
  2. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #2
    The equivalent would be down in /var/db/dslocal somewhere. Something like:

    /var/db/dslocal/nodes/Default/users/yourshortname.plist

    [read it (with sudo) and decide for yourself i guess. ;) ]
     
  3. MrCheeto thread starter macrumors 68030

    MrCheeto

    Joined:
    Nov 2, 2008
    #3
    OK I did that but after creating a new user at the Setup screen, in Preferences>Sharing, there are some left over settings from the last user...
     
  4. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #4
    Which "left over settings"? (specifically)
     
  5. MrCheeto thread starter macrumors 68030

    MrCheeto

    Joined:
    Nov 2, 2008
    #5
    Under Sharing>File Sharing it lists the old user's public folder as a folder that can be shared, though it no longer exists.
     
  6. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #6
    Okay, I'll have a look/see (once i get off my iPad).
     
  7. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #7
    its not necessary - but does come in handy for custom DNS setting.
     
  8. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #8
    It seems the following items get affected by sharing folders with System Prefs->Sharing, and may retain traces of former users (and/or items they've shared):
    /var/db/samba/smb.shares
    /var/db/dslocal/indices/Default/index
    /var/db/dslocal/nodes/Default/config/SharePoints/*.plist
    /var/db/dslocal/nodes/Default/groups/com.apple.sharepoint.*.plist​
    The asterisk is a wildcard which will match whatever filename(s) happen(s) to fit... when used on the command line anyway.

    A more exact list (as far as your specific Sharing query goes) could also be obtained by running this command:

    sudo grep -lr yourshortname /var/db/dslocal /var/db/samba

    Notes:
    1. if run in single-user mode or a root shell, skip the sudo part.
    2. replace yourshortname with the actual name of course (or the name of some folder you shared)

    As to what exactly one should do to purge one's name from such files goes, i'll not be posting a thorough 'how-to' or anything. The only easy cases are ones where the file itself is specifically named for the user. E.g.,:
    yourshortname.plist

    or

    Your Full Name's
    Public Folder.plist​
    ...as those files could be deleted entirely. Other items (such as admin.plist and staff.plist) could theoretically be editednot deleted! —using extreme caution, to surgically remove the relevant entries. [note that dscl isn't normally available in SU mode, but a basic editor like nano could be used instead... unless one cared to load all the services needed (which i'm not familiar with) to support running dscl in SU mode.]

    The tricky file (IMO) is /var/db/dslocal/indices/Default/index, because that appears to be the only one not comprised of "plain" text... and i have no idea what the effect of erasing it would be. Maybe there's some tool which could be used to properly edit that SQLite database. Or maybe it doesn't matter much (?). Perhaps teh google knows.


    [p.s.; looks like you might wanna consider changing the thread's title, if still possible.]
     
  9. MrCheeto thread starter macrumors 68030

    MrCheeto

    Joined:
    Nov 2, 2008
  10. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #10
    I just spotted the archive "/var/db/dslocal-backup.xar" lounging around as well. So i suppose --if the new owner went looking for stuff --they could use the xar tool to extract, view and/or even restore past configs from that.

    Also the item "/var/db/locate.database" might fall under the useful housecleaning category, as it will reveal old pathnames (even if they no longer exist).
     
  11. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #11
    if the files are already deleted and filenames isnt an issue - i dont see the problem.

    this method seems like a big PITA rather then a direct reinstall tbh :\
     
  12. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #12
    It's not a problem... it's an exercise.

    But perhaps if one donates their Mac to the local school or Aunt Debbie... and then file names such as "Deep Throat" or "Jurassic Pork" show up when the new owner (with the same uid 501) does a locate *.mov search, it might be embarrassing.

    So... there's nothing wrong with studying the concept and trying to cover all bases. No one is saying that users must do this.


    It depends on how nice you want to be to the new owner. I usually relinquish my old Macs in a 100% fully up-to-the-minute state. [all software updates to that day installed.]

    Anyway --if Unix bothers you this much --why even read the thread. :)
    I find it fun.
     
  13. MrCheeto thread starter macrumors 68030

    MrCheeto

    Joined:
    Nov 2, 2008
    #13
    Seems good. All I have to do is remove my *User* folder (assuming all of my information was only kept within my User, as I do) delete Preferences, remove .AppleSetupDone to zip it up and if I configured any network settings I'd just grep my user name.

    I left the network settings unconfigured on a PowerBook then went through the process and created a new user through the Setup and there was no trace that anybody had rummaged around.

    I just can't help but play with every mac I own! I've had three PowerBook G4's in the past several weeks and I can't keep my grubby hands off of them! My MacBook Pro is lyk soez jelluz!

    LUV Unix! And thanks!
     

Share This Page