Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I edit the Hosts file on Ubuntu 10.10?

Posted on 2011-02-15
8
Medium Priority
?
1,354 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 10

Assisted Solution

by:abbright
abbright earned 150 total points
ID: 34897873
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 150 total points
ID: 34897903
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
ID: 34898327
>> "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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 35

Expert Comment

by:torimar
ID: 34898341
0
 

Author Comment

by:CCB-Tech
ID: 34899091
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
ID: 34899250
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 450 total points
ID: 34899397
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
ID: 34900692
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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

705 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