Jump to content



Photo

Access Hosts File Mac OS X Lion


  • Please log in to reply
17 replies to this topic

#1 .Neo

.Neo

    Generic User

  • Joined: 14-September 05
  • OS: OS X Yosemite
  • Phone: iPhone 5s

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.

  • Tech Issues Solved: 1
  • Joined: 11-January 09

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

  • Joined: 09-October 03
  • 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

  • Joined: 24-August 10
  • 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é

  • Joined: 20-June 04
  • Location: BC, CANADA

Posted 21 July 2011 - 03:18

VI/VIM FTW!

#6 +KoL

KoL

    Javier Ocasio

  • Joined: 04-October 01
  • Location: Puerto Rico
  • OS: Mac OS X 10.9.1
  • Phone: iPhone 5

Posted 21 July 2011 - 03:18

Terminal

sudo nano /private/etc/hosts


#7 OP .Neo

.Neo

    Generic User

  • Joined: 14-September 05
  • OS: OS X Yosemite
  • Phone: iPhone 5s

Posted 21 July 2011 - 06:02

Thanks The Protagonist and Kol! That did the trick!

#8 PurpleHaze420

PurpleHaze420

    Neowinian

  • Joined: 05-November 01
  • Location: Wales
  • OS: Windows 7 / OSX
  • Phone: iPhone 5S

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.

  • 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

Medfordite

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 16-March 06
  • Location: Medford Oregon
  • OS: Win 8.1 Pro
  • Phone: HTC One M7 - Blue

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 Senior

  • Joined: 26-September 02
  • Location: Virginia, USA
  • OS: OS X Yosemite
  • Phone: iPhone 5s

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 Senior

  • 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

Elliott

    Neowinian Senior

  • Joined: 26-September 02
  • Location: Virginia, USA
  • OS: OS X Yosemite
  • Phone: iPhone 5s

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 Senior

  • Joined: 09-October 02

Posted 21 July 2011 - 20:48

It's the sandbox.

Posted Image

#15 offroadaaron

offroadaaron

    root can touch you anywhere

  • Joined: 02-May 02
  • 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