Jump to content

Welcome Guest! To access all forums & features, please register an account or sign-in. → Why register?




Photo

Access Hosts File Mac OS X Lion


  • Please log in to reply
17 replies to this topic - - - - -

#1 .Neo

.Neo

    Generic User

  • 17,060 posts
  • Location: Amsterdam, NL
  • OS: OS X Mountain Lion
  • Phone: iPhone 5

Posted 21 July 2011 - 01:18

On Mac OS X Snow Leopard and below I used to be able to access the Hosts file using this command:

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts
However, after installing Mac OS X Lion today I can't anymore. Any suggestions how to open and edit the file? Thanks in advance.


#2 Unrealistic

Unrealistic

    Laughter is all we have.

  • 1,693 posts

Posted 21 July 2011 - 03:11

On Mac OS X Snow Leopard and below I used to be able to access the Hosts file using this command:

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts
However, after installing Mac OS X Lion today I can't anymore. Any suggestions how to open and edit the file? Thanks in advance.


I always just use TextWrangler to edit it. Sudo worked for me though (not using TextEdit.app).

#3 AlexMagik

AlexMagik

    Over the Top

  • 487 posts
  • Location: China
  • OS: MacOS X

Posted 21 July 2011 - 03:16

sudo nano /etc/hosts

#4 The Protagonist

The Protagonist

    time for a little wget magic

  • 1,415 posts
  • Location: localhost
  • OS: Debian Linux, Kernel 3.2.6

Posted 21 July 2011 - 03:16

sudo nano /etc/hosts


once your done

ctrl+o then crtl+x



#5 rajputwarrior

rajputwarrior

    olé olé olé olé

  • 12,924 posts
  • Location: BC, CANADA

Posted 21 July 2011 - 03:18

VI/VIM FTW!

#6 +KoL

KoL

    Javier Ocasio

  • 9,888 posts
  • Location: Puerto Rico

Posted 21 July 2011 - 03:18

Terminal

sudo nano /private/etc/hosts


#7 OP .Neo

.Neo

    Generic User

  • 17,060 posts
  • Location: Amsterdam, NL
  • OS: OS X Mountain Lion
  • Phone: iPhone 5

Posted 21 July 2011 - 06:02

Thanks The Protagonist and Kol! That did the trick!

#8 PurpleHaze420

PurpleHaze420

    Neowinian

  • 355 posts
  • Location: Wales

Posted 21 July 2011 - 17:05

I didn't know how to achieve this through Terminal, will come in handy. Thanks. :)

#9 chrispinto

chrispinto

    Objective Apple products fan.

  • 1,054 posts
  • Location: Bournemouth, UK
  • OS: OS X 10.8 Mountain Lion - iMac 27" 2.7GHz i5 Quad - 12Gb Ram

Posted 21 July 2011 - 17:07

Terminal all the way for quick hosts file editing
Then a quick reboot or could just flush the cache for 'instant' updating

#10 Medfordite

Medfordite

    Neowinian Senior

  • 2,221 posts
  • Location: Medford Oregon
  • OS: Win 8 Home
  • Phone: Samsung Galaxy Axiom

Posted 21 July 2011 - 17:11

Looks as ifGasmask for Macwill work on Lion and that also lets you edit your hosts files in a Gui.

#11 +Elliott

Elliott

    Neowinian ULTRAKILL

  • 11,081 posts
  • Location: Virginia, USA
  • OS: OS X Mountain Lion
  • Phone: iPhone 5 (iOS 6)

Posted 21 July 2011 - 17:22

Then a quick reboot or could just flush the cache for 'instant' updating

Does OS X really cache entries from the hosts file? Seems weird to me.

#12 Xtreme $niper

Xtreme $niper

    Neowinian Wise One

  • 4,943 posts
  • Location: Canada

Posted 21 July 2011 - 19:40

Still doesn't really explain why he can't use TextMate to edit the file anymore...?

#13 +Elliott

Elliott

    Neowinian ULTRAKILL

  • 11,081 posts
  • Location: Virginia, USA
  • OS: OS X Mountain Lion
  • Phone: iPhone 5 (iOS 6)

Posted 21 July 2011 - 20:41

Still doesn't really explain why he can't use TextMate to edit the file anymore...?

TextEdit, not TextMate. You can still use TextMate just fine. The problem probably has something to do with sandboxing in Lion.

#14 vetgiga

giga

    Neowinian Super Cool

  • 19,567 posts

Posted 21 July 2011 - 20:48

It's the sandbox.

Posted Image

#15 offroadaaron

offroadaaron

    root can touch you anywhere

  • 2,643 posts
  • Location: Australia

Posted 21 July 2011 - 23:05

Terminal all the way for quick hosts file editing
Then a quick reboot or could just flush the cache for 'instant' updating



You don't need to reboot LOL's