Solved

How do I edit the Hosts file on Ubuntu 10.10?

Posted on 2011-02-15
8
1,316 Views
Last Modified: 2012-06-27
I cannot edit the Hosts file on my Ubuntu 10.10 install. I have tried using the following commands:

sudo gedit \etc\hosts
sudo nano \etc\hosts
sudo vi \etc\hosts

None have worked. Althought the Vi editor MAY work, I am having difficulty doing so. What would I need to do to get Gedit to work on the Hosts file?
0
Comment
Question by:CCB-Tech
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 10

Assisted Solution

by:abbright
abbright earned 50 total points
Comment Utility
Pathnames in Linux are written using "/" not "\", so try using
sudo gedit /etc/hosts
sudo nano /etc/hosts
sudo vi /etc/hosts
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 50 total points
Comment Utility
Hi,

first of all, don't use backslashes ( \ )! Use the normal slashes ( / ) as directory separators.

gedit is the default editor in Ubuntu.
Should it be missing nevertheless install it with:

apt-get gedit

Here is a vi tutorial:
http://www.unix-manuals.com/tutorials/vi/vi-in-10-1.html
http://www.unix-manuals.com/tutorials/vi/vi-in-10-2.html

wmp
0
 
LVL 35

Expert Comment

by:torimar
Comment Utility
>> "What would I need to do to get Gedit to work on the Hosts file?"

Apart from the slashes which you put wrongly and which have already been addressed, if you really want to use Gedit, which is a graphical Gnome application, you should launch it via the graphical sudo command 'gksudo', i.e.:

# gksudo gedit /etc/hosts

See this as reference: https://help.ubuntu.com/community/RootSudo#Graphical sudo

'nano' doesn't require any additional thought, and also is much simpler to use than vi, so I'd always recommend to use 'nano'.
0
 
LVL 35

Expert Comment

by:torimar
Comment Utility
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:CCB-Tech
Comment Utility
LOL, yikes I knew I would get the slashes wrong. I posted this question in a hurry before a meeting. I had been running the commands with the correct slashes. And gedit is installed and running fine. The problem I had was that no matter what I've tried I am not able to save my changes. I just tried using gksudo and sudo and neither worked. It prompts for the root password and then runs fine. When I bring up gedit the save options are all greyed out. Leading me to think something is amiss with the permissions. Although I just tried Nano again and it seems to be working. Any idea WTF might have caused this to prevent gedit from working? Nano is fine but gedit is simpler.

Thanks for all the quick responses!
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
Maybe you forgot sudo sometimes?

And sudo does not prompt for root's password, it prompts for your (the user's) password!

wmp
0
 
LVL 35

Accepted Solution

by:
torimar earned 150 total points
Comment Utility
There are several reports about Gedit sometimes behaving strangely when saving, whereas other editors, graphical ones included, are fine.

Most of the time this has turned out to have to do with the fact that Gedit creates a temporary copy of the edited file which is later saved to disk as a backup.
Try this:
In Gedit, go Edit > Preferences > Editor, and look for "Create a backup copy of files before saving".
If it is checked, uncheck; if it is unchecked, check.
Then try editing and saving again.
0
 

Author Closing Comment

by:CCB-Tech
Comment Utility
I did try what you mentioned about the backup file. It was unchecked. I checked it, closed gedit, and re-opened it to verify that it stuck. Then I ran the gksudo command to edit the file. No joy :(. Oh well. I tried nedit as an alternative since you mentioned that gedit sometimes has issues. Worked a treat! Thanks for everyones help!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

BIND is the most widely used Name Server. A Name Server is the one that translates a site name to it's IP address. There is a new bug in BIND (https://kb.isc.org/article/AA-01272), affecting all versions of BIND 9 from BIND 9.1.0 (inclusive) thro…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now