How to edit /etc/hosts?
I need to add a hostname and IP address to /etc/hosts, so that I can access server at a hosting site, after I connect via VPN. The hostname that I need to use is not in the DNS, so I need to add it manually to /etc/hosts. I can't seem to find my root pwd, but I have an account with Admin access. Isn't there some tool for editing this file? Otherwise, I'll need to enable the root account somehow.
Use a tool such as TextWrangler which allows administrators to authenticate to root, or sudo with a command line text editor.
(45358)
Similar Messages
-
How to edit etc/apache2/httpd.conf? Pica won't take my password.
I can navigate to the pico prompt in terminal ... but when it asks for pw, I try to type, the cursor just blinks, doesn't move, nothing.
But if there's another way to edit this file, I'll try.
Just want to uncomment the line about php5 module.
Thanks!!! xoxomagaroni wrote:
I like the tutorial, but yeah you are right, it's sudo, not pico that's not taking my pw. I can sudo pico or sudo vi, either way it asks me for my password but then the cursor doesn't respond to my typing.
I'm used to vi. You use control keys to navigate and make changes. It has two modes, command and insert. In command mode, to delete the '#' character, for example, move the cursor to '#' and type 'x' to delete it. Type 'i' to enter insert mode and add new text. Press 'esc' to go back to command mode.
There are numerous ways to save and quit. Usually you type 'ZZ' to save and quit. On some of these system files, their permissions are too restrictive for that. You have to do it the hard way. Type ':w!' to save. The 'w' is for "write" and the '!' is to force a write on a read-only. Then you can quit with "q!'.
I've never edited an administrative file with pico.
I can't even chmod to give myself rights to write to httpd.conf . "Operation not permitted."
Don't try that. Many tools will rightfully refuse to even launch if they detect that their administrative config files have been incorrectly modified.
internet chatter seems to suggest this 10.7.x is, like, super duper secure. And I'm new to macs. I'm logged in as admin, I have all the permissions I can find myself via finder ... but maybe there's a double-secret admin ...
There is, it is "sudo". Only an admin user has the ability to use sudo to gain root permissions. -
On OS X client I routinely edit /etc/hosts to add names for my various servers, local and remote, as well as to block some of the better known malware and virus sites and the more egregious Internet hucksters -- er, ad sites.
10.1.10.47 rama
10.1.10.48 athene
144.15.97.289 web yogurt davone
127.0.0.1 scum.sucker.com
127.0.0.1 evil.banners.net
etc.
I'm hesitant to do the same thing on Server (for example, I know better than to manually edit /etc/apache2/http.conf). My current hosts file in client is over 2500 lines, so if I have to manage this through Server Admin I'd like to get started now.Ever since I started using OS X Server, I haven't touched /etc/hosts. I would use the DNS server to deal with the scum.suckers.com, and Workgroup Manager (and DNS again, unfortunately) to manage the actual hosts on your network. I'm curious on the efficacy of managing 2500 actual hosts with Workgroup Manager, though.
-
Editing etc\hosts file on windows xp for apps. problem post installation.
Hi all,
I was able to install 11.5.10.2 apps on my win xp prof machine. During that process I had to edit the etc/hosts file in windows directory as a work around for that domain name field during installation. Also added the primary DNS suffix as 'suneel.com' . I gave the domain name as 'suneel.com' during installation. The RapidWiz is taking localhost as the system name and referring to this system as localhost.suneel.com, though the actual system name is 'websoft-xp' .
The host file on Apps machine has the following entries:
127.0.0.1 localhost
127.0.0.1 localhost.suneel.com suneel.com
127.0.0.1 websoft-xp.suneel.com
So when I connect to apps login server from other systems in lan, I've to edit their hosts file and add an entry for localhost.suneel.com to point to its ip address or else the apps throws an error after logging in as operations/welcome using a different url say 192.168.1.4:8000 . Is there a way to get around this issue?
More over I'm not able connect to VIS db from other systems. The oracle clients give an error 'No listner' at this address. (The original listener was listening at localhost.suneel.com:1521). So I tried to create a new listerner from Net Manager that actually listens at websoft-xp (the real system name) but it throws me an error 'A valid log file is required' while saving the network configuration and prevents me from saving the network configuration.
Did I do something wrong with the hosts file during installation or did i miss any entries in that file thats causing this? Any solutions for the above problems will be appreciated?
Thanks
Suneel
Message was edited by:
suneelgvWell I tried that option but for some reason it didn't work for me. It kept giving the tns:connection closed error. Then I searched in metalink and found this note : Note:333158.1
It suggested setting tcp.validnode_checking = no
in sqlnet.ora. in
F:\oracle\visdb\9.2.0\network\admin\VIS_websoft-xp
And it works. Hope this helps someone facing a similar problem. Good luck.
BTW how do I run autoconfig?
Thanks,
Suneel Gundlapalli -
Hi all,
Please help sorting my terminal, I'm having problem with my iTune everytime I want to update or restore my ipad or iphone, it keep saying "this device isn't eligible for the requested build"
Now I tried to edit the etc/hosts using the Terminal, but suddenly all the script
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
#74.208.10.249 gs.apple.com
#127.0.0.1 gs.apple.com
are all gone i think i accidentally deleted it. so what I did was I copy this from forum and paste it to terminal.
But i'm having problem how to save it, when I press ^O it goes like this:
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
#74.208.10.249 gs.apple.com
#127.0.0.1 gs.apple.com
File Name to Write: etc/hosts
^G Get Help ^T To Files M-M Mac Format M-P Prepend
^C Cancel M-D DOS Format M-A Append M-B Backup File
and I dont know how to save it. when I press ^X doesn't save at all.
Please Help me.
Thank you in advance.Well lets make things easier, get out of Terminal by just Quiting it or Force Quit.
Download the free TextWrangler here
http://www.barebones.com/products/textwrangler/download.html
Now under the File Menu >Open File by Name
/etc/hosts
It should look like this, if not then just copy and paste it in.
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
Now save it and give it your admin password and that's it. Easy as pie.
Terminal's pico and vi editing programs have a lot to be desired, but serve the basic puposes.
With Terminal you need to enter
sudo pico /etc/hosts
then enter your admin password to access a system file.
It can only be done via a Admin account, however with TextWrangler not only is it much easier, you can also access system files from a Standard user account.
the two lines
#74.208.10.249 gs.apple.com
#127.0.0.1 gs.apple.com
You have there are "commented out" with the "#" symbol, basically your telling the computer to "ignore this line"
Why you think messing with your /etc/hosts file is going to solve your primary issue with iTunes/iPad/iPhone is beyond me.
Did you ever think that perhaps your two devices are too old for the "requested build"? -
How to use /etc/hosts file
how to get Mac OS "X" 10.6.x to use /etc/hosts file and/or /etc/resolv.conf file(s) (ala Unix-style); instead of using some other mechanism?
I 'thought' that SnowLeopard (somewhere in the "Support" arena) told me that 10.6 (SnowLeopard) did NOT use /etc/hosts, but I am corrected, and now understand through a number of replies here (Apple-Support-Discussions) and other responses that SnowLeopard (10.6 (I'm at 10.6.7) DOES USE /etc/hosts... - AND YES _ I'm attempting to prevent some things, and have some web-site-development-things go to a local-server, etc. etc. etc. - but - I guess my 'answer' was supplied by a number of people and that my ...nix background and my familiarity with /etc/hosts is fine and working well...
thanks to one and all who helped! - I'm now also well-acquainted with dscl, dscacheutil, and other such utilities...
THANKSSSSS!!!!!!! -
Unable to edit /etc/hosts with permission denied error
[15:45:02][rabbie@sandnigga:~]# sudo cat /etc/hosts
Password:
cat: /etc/hosts: Permission denied
[15:45:09][rabbie@sandnigga:~]#
Basically that's my problem right there. I cant edit / view / change the hosts file on my macbook pro but I can delete it and create a new one. If I do delete it and create a new one, that new file then has the same problem only a few minutes later.
Does anyone have any ideas ?
I have also tried to change the ownership and permissions of the file:
[15:45:09][rabbie@sandnigga:~]# ls -la /etc/hosts
-rwxrwxrwx 1 root wheel 290 18 Sep 20:38 /etc/hosts
No luck.
Thanks in advance for any help.Hey Bob,
The hosts file is often edited and added to by network administrators as well as web developers to force your local computer to resolve DNS for sites whos DNS is not yet publicly available.
I actually found the problem and root cause behind this. I installed BitDefender Antivirus on my MacBook Pro and the uninstall script did not successfully remove all settings / files. There were still some BitDefender files locking processes and files on my Mac and so I just ended up Wiping my drive and re-installing Mountain Lion.
Thanks for your attempt to help anyway. -
How to edit /etc/vfstab
I created a file system earth in /earthpool (zpool). I mounted the file system on a directory /earth. But, when I reboot my machine it doesn't load the file systems and the zpool and zfs shows no pools available and no datasets respectively. I am using Solaris 10 running on X4500. Could you please give me the syntax of how to change the /etc/vfstab file.
device to mount device to fsck mount point FS type fsck pass mount at boot mount options
earthpool/earth /earth zfs yes
Is the above syntax correct ? Do I have to separate it using a hyphen or a space is enough ?
Thank youI assume you created the filesystem like:
# zfs create earthpool/earth And you want to mount it as /earth ??
Then you would use:
# zfs set mountpoint=/earth earthpool/earth -
How to edit podcast hosted on mypodcast and now added to itunes?
i recently added my podcast from mypodcast.com to itunes. i changed the info later on mypodcast.com including the pic. how do i update this info on itunes?
Just make the changes in the feed an reupload it. It will normally take 1-2 days - sometimes longer - for new episodes and other information changes to appear.
If you want to change the picture you should give the new picture a new filename and change the feed accordingly: iTunes caches the image and if you change the picture without changing the filename it's unlikely iTunes will realise it's changed. If you're using an online service to make your podcast, as seems to be the case, you may not be able to change the filename so all you can do it wait and hope the change is picked up eventually. -
Hosts-update: automatically append the mvp blocklist to /etc/hosts
This util written by wintervenom has actually been in the AUR for going on 2 years now.
What it does:
Updates /etc/hosts with the mvps blocklist to prevent thousands of parasites, hijackers and unwanted adware/spyware/privacy websites from working.
Operation is trivial:
1) Edit /etc/hosts.local to match the hostname of your system and adjust the domainname as needed. Also add any hosts that you wish to keep i.e. other PCs on your network.
2) Run /usr/bin/update_hosts as root which will append /etc/hosts.local to the mvps blocklist and apply some post processing writing the final file to /etc/hosts automatically.
3) (Optional) Add a cronjob under root crontab at some interval to keep your /etc/hosts fresh.
AUR: https://aur.archlinux.org/packages/hosts-update
Github: https://github.com/graysky2/hosts-update
Original thread: https://bbs.archlinux.org/viewtopic.php?id=106367
Enjoy!
Last edited by graysky (2013-12-11 17:09:06)Sure you can, but not in this particular tool. There is a script written by haarp designed to run on a tomato-usb powered router that does just this. I host the code here: https://github.com/graysky2/adblock
EDIT: I can't remember if it pulls from the same urls as pgl does but you can certainly modify the code to do it.
Last edited by graysky (2013-12-11 19:52:02) -
/etc/hosts, /etc/hostname.bgeN configuration
I am writing this to get help.
I have a Solaris 10 box.
bash-3.00$ uname -a
SunOS soft19 5.10 Generic_125100-10 sun4u sparc SUNW,Netra-240
I have the following stuff on this box,
bash-3.00$ cat /etc/hosts
# Internet host table
127.0.0.1 localhost
10.9.48.244 soft19-bge1 Secondary
10.9.16.121 soft19 loghost
#10.9.48.244 soft19 Secondary
bash-3.00$ cat /etc/hostname.bge0
soft19
bash-3.00$ cat /etc/hostname.bge1
soft19-bge1
bash-3.00$ ifconfig -a
lo0: flags=2001000849 mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
bge0: flags=1000843 mtu 1500 index 2
inet 10.9.16.121 netmask ffffff00 broadcast X.X.X.255
bge1: flags=1000843 mtu 1500 index 3
inet 10.9.48.244 netmask ffffff00 broadcast X.X.X.255
In our code base, we have the following,
struct hostent *hp;
hp = ACE_OS::gethostbyname(myhostname); // myhostname is soft19
hp->h_addr_list[0] will give 10.9.16.121
Everything is correct here!!
Now I change the configuration a bit,
bash-3.00$ cat /etc/hosts
# Internet host table
127.0.0.1 localhost
#10.9.48.244 soft19-bge1 Secondary
10.9.16.121 soft19 loghost
10.9.48.244 soft19 Secondary
and now
hp->h_addr_list[0] will give 10.9.16.121
hp->h_addr_list[1] will give 10.9.48.244
but when I reboot the system, I get the following,
bash-3.00$ ifconfig -a
lo0: flags=2001000849 mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
bge0: flags=1000843 mtu 1500 index 2
inet 10.9.16.121 netmask ffffff00 broadcast X.X.X.255
bge1: flags=1000843 mtu 1500 index 3
inet 0.0.0.0 netmask ffffff00 broadcast X.X.X.255
And I know this is because
bash-3.00$ cat /etc/hostname.bge1
soft19-bge1
Now I change /etc/hostname.bge1 to have just soft19
and I reboot the system and what I see is this
bash-3.00$ ifconfig -a
lo0: flags=2001000849 mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
bge0: flags=1000843 mtu 1500 index 2
inet 10.9.16.121 netmask ffffff00 broadcast X.X.X.255
bge1: flags=1000843 mtu 1500 index 3
inet 10.9.16.121 netmask ffffff00 broadcast X.X.X.255
Which is correct again!
Now my question is
With this
struct hostent *hp;
hp = ACE_OS::gethostbyname(myhostname); // myhostname is soft19
I want to have the following,
hp->h_addr_list[0] will give 10.9.16.121
hp->h_addr_list[1] will give 10.9.48.244
How can I get this even if the system reboots?Hi, Thanks, but I know this. And was expecting the same.
But my question still remains unanswered..
How to tweak /etc/hosts and /etc/hostname.bgeN files for....
With this code
struct hostent *hp;
hp = ACE_OS::gethostbyname(myhostname); // myhostname is soft19
I want to have the following,
hp->h_addr_list[0] will give 10.9.16.121
hp->h_addr_list[1] will give 10.9.48.244
One more thing, I want to get this all the time, even my system reboots.
I know a method to get below [by modifying /etc/hosts file]
hp->h_addr_list[0] will give 10.9.16.121
hp->h_addr_list[1] will give 10.9.48.244
but this will not work when the system reboots? I am looking for a permanent solution.
Thanks,
Atul -
/etc/hosts works but gets overwritten every boot
On my system (10.6.8) I can edit /etc/hosts and the changes take effect immediately. The problem is that every time I reboot, my changes are overwritten. Does anyone know what could cause this? BTW this is the exact same unsolved issue found in this dead archived thread.
"servy" is a computer on my lan that uses DHCP and registers its name with my router which serves DNS. If I comment out the line for "servy" in my hosts file, it immediately takes effect and I can successfully ping it, or lookup its address with "dscacheutil -q host -a name servy", but as soon as I reboot, the /etc/hosts file no longer has the comment in that line. It's like there's a "last known good" copy of the hosts file somewhere and OSX or some service is restoring it every boot.
timac:~ tim$ cat /etc/hosts
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
192.168.2.100 servy
timac:~ tim$ ls -la ~/Library/LaunchAgents/
total 32
drwx------ 6 tim staff 204 Nov 13 19:22 .
drwx------+ 42 tim staff 1428 Dec 6 21:21 ..
-rw-r--r-- 1 tim staff 892 Nov 13 2009 [email protected]t.plist
-rw-r--r-- 1 tim staff 425 Nov 13 19:22 com.apple.FolderActions.enabled.plist
-rw-r--r-- 1 tim staff 517 Nov 13 19:22 com.apple.FolderActions.folders.plist
-rw-r--r-- 1 tim staff 677 Oct 22 17:06 org.virtualbox.vboxwebsrv.plist
timac:~ tim$ ls -la /Library/LaunchAgents/
total 16
drwxr-xr-x 4 root wheel 136 Jan 9 12:31 .
drwxrwxr-t+ 56 root admin 1904 Mar 5 2010 ..
-rw-r--r-- 1 root wheel 635 Sep 9 09:04 com.cisco.anyconnect.gui.plist
-rw-r--r-- 1 root wheel 786 Jul 10 2011 com.google.keystone.agent.plist
timac:~ tim$ ls -la /Library/LaunchDaemons/
total 24
drwxr-xr-x 6 root wheel 204 Jan 9 12:31 .
drwxrwxr-t+ 56 root admin 1904 Mar 5 2010 ..
-rw-r--r-- 1 root wheel 485 Aug 31 2009 com.DuetDaemon.plist
-rw-r--r-- 1 root wheel 669 Feb 17 2011 com.apple.third_party_32b_kext_logger.plist
-rw-r--r-- 1 root wheel 562 Sep 9 09:04 com.cisco.anyconnect.vpnagentd.plist
-rw-r--r-- 1 root wheel 790 Jul 10 2011 com.google.keystone.daemon.plist
timac:~ tim$ ls -la /Library/StartupItems/
total 0
drwxr-xr-x 4 root wheel 136 Dec 31 2010 .
drwxrwxr-t+ 56 root admin 1904 Mar 5 2010 ..
drwxr-xr-x 5 root wheel 170 Jan 10 09:23 VirtualBox
drwxr-xr-x 4 root wheel 136 Mar 7 2010 rEFItBlesser -
How do I edit the hosts file in Lion
I tried to edit the hosts file in Lion with: sudo nano /private/etc/hosts. Then entered Password. The window came up blank evev though I know there is data there.
Thanks BD for your response. I have looked at Youtube where they are demonstrating how to do this by using sudo nano /etc/hosts. After entering the Password it shows a screen with the text of the hosts file. On the bottom of the screen it shows the number of lines read. When I do the same thing I get a blank screen and on the bottom it says no file. I am either doing something wrong or this does not work. I even tried changing the permissions of the hosts file to R & W for system, wheel, and everyone. This also did not work. I have not tried Hostal yet but if I can't find a simple way to text edit the hosts file I will give it a try.
-
How to edit host file...
I have ICS on my SK17i . I want to edit my /etc/host file. How is it possible.
Solved!
Go to Solution.Since host file is a system file
You need to root your phone and then use root explorer > mount R/W > open with text editor
May i know what actually you want to do ?
Why do you want to edit host file ?
Discussion guidelines.
Message me or any other moderator to seek help regarding moderation. -
HT2478 how to edit the picture you put on the desktop, center it etc.
how to edit the picture you put on the desktop, center it etc.
On what Mac running what version of OS X?
Maybe you are looking for
-
Safari on my IPad 4 will not open. It will come up but is blank and will not let me type a search or navigate anywhere.
-
Hi Guy's, creation of new infotype we are using Transation code:PM01, when we enter this TS it displays differnt tabs like : Create infotype,infotype version, Screen structure.. presnt require ment is to enhance the one tab to that TS.(Ex: create t
-
If I have an apple loop which I want to play at twice the tempo of the song I'm using it in, how do I do it? My song is at 80 bpm and when I drop my apple loop in I want it to play back at 160 bpm not 80 bpm. Is there an easy way to do this?
-
Why won't my Mac lock when I shut it down?
I have recently found out that my Mac won't lock after I shut it down. And if I leave it in sleep mode, all I have to do to bypass the password screen is just restart it. What can I do to fix this?
-
I have the 60 gig iPod. For some reason, the songs are getting quieter. I've tried the Sound Enhancer option, MP3 Gain and even the iTunes sound setting. I had to use the sound slider on a couple songs because they're way loud, but all the other song