Solved

How do I edit the Hosts file on Ubuntu 10.10?

Posted on 2011-02-15
8
1,324 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
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 50 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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 150 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
nagios remote hosts 9 56
Linux haproxy: stop temporary haproxy service 9 44
cannot rename datastore 3 48
how to configure linux OS using Ubuntu 7 44
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

777 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