Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I edit the Hosts file on Ubuntu 10.10?

Posted on 2011-02-15
8
Medium Priority
?
1,367 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 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
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
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 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.
Suggested Courses
Course of the Month11 days, 21 hours left to enroll

916 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