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



Access Hosts File Mac OS X Lion


17 replies to this topic - - - - -

#1 .Neo

    Generic User

  • 16,993 posts
  • Joined: 14-September 05
  • 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

    Laughter is all we have.

  • 1,692 posts
  • Joined: 11-January 09

Posted 21 July 2011 - 03:11

View Post.Neo, on 21 July 2011 - 01:18, said:

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

    Over the Top

  • 481 posts
  • Joined: 09-October 03
  • Location: China
  • OS: MacOS X

Posted 21 July 2011 - 03:16

sudo nano /etc/hosts

#4 The Protagonist

    time for a little wget magic

  • 1,415 posts
  • Joined: 24-August 10
  • Location: localhost
  • OS: Debian Linux, Kernel 3.2.6

Posted 21 July 2011 - 03:16

Quote

sudo nano /etc/hosts

once your done

Quote

ctrl+o then crtl+x


#5 rajputwarrior

    olé olé olé olé

  • 12,924 posts
  • Joined: 20-June 04
  • Location: BC, CANADA

Posted 21 July 2011 - 03:18

VI/VIM FTW!

#6 +KoL

    Javier Ocasio

  • 9,884 posts
  • Joined: 04-October 01
  • Location: Puerto Rico

Posted 21 July 2011 - 03:18

Terminal

sudo nano /private/etc/hosts


#7 OP .Neo

    Generic User

  • 16,993 posts
  • Joined: 14-September 05
  • 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

    Neowinian

  • 352 posts
  • Joined: 05-November 01
  • 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

    Objective Apple products fan.

  • 1,054 posts
  • Joined: 15-September 03
  • 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

    Neowinian Senior

  • 2,205 posts
  • Joined: 16-March 06
  • 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

    Neowinian ULTRAKILL

  • 11,080 posts
  • Joined: 26-September 02
  • Location: Virginia, USA
  • OS: OS X Mountain Lion
  • Phone: iPhone 5 (iOS 6)

Posted 21 July 2011 - 17:22

View Postchrispinto, on 21 July 2011 - 17:07, said:

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

    Neowinian Wise One

  • 4,943 posts
  • Joined: 16-July 04
  • 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

    Neowinian ULTRAKILL

  • 11,080 posts
  • Joined: 26-September 02
  • Location: Virginia, USA
  • OS: OS X Mountain Lion
  • Phone: iPhone 5 (iOS 6)

Posted 21 July 2011 - 20:41

View PostXtreme $niper, on 21 July 2011 - 19:40, said:

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

    Neowinian Super Cool

  • 19,567 posts
  • Joined: 09-October 02

Posted 21 July 2011 - 20:48

It's the sandbox.

Posted Image

#15 offroadaaron

    root can touch you anywhere

  • 2,642 posts
  • Joined: 02-May 02
  • Location: Australia

Posted 21 July 2011 - 23:05

View Postchrispinto, on 21 July 2011 - 17:07, said:

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