LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to edit host file in Linux (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-edit-host-file-in-linux-686561/)

kbklinux 11-27-2008 01:48 AM

How to edit host file in Linux
 
Hi All,

Iam bala and im interested in linux OS. can some one please help me how to edit the host file in linux.

Thanks in advance,
Bala

roy_lt_69 11-27-2008 02:00 AM

Are you talking about the /etc/hosts file?
If so, then you will need to log in as root (or the equivalent) in order to edit it.
Do ls -l /etc/hosts to see who can write to the file (usually root only)!

jiobo 11-27-2008 02:02 AM

Are you asking how to edit a text file in Linux? Have you booted up and logged in already? If so, then you can use any text editor to edit the file and save it. You can usually find the text editors from the menu options or you can enter in a shell command to start an editor from a terminal window such as "vi", "emacs", "pico", "nano", "kate", "gedit", etc. Many of these have documentation on the internet, and some have man pages as well. From a command line in the shell, type "man vi" to read about that editor, or "man nano" to read about that, etc. For opening the file to edit it: "nano <filename>".

chrism01 11-27-2008 02:06 AM

... and take a copy first in case you make a mistake in the editor.

kbklinux 11-27-2008 08:24 AM

Thank You all... Yes iam talking about /etc/host file only..

Thank You
Bala

jstephens84 11-27-2008 10:36 AM

depends on what you want to use. But as root you can use pico, emacs or vim. I am a vim fan so you just type
Code:

vim /etc/hosts
Just choose you editor of choice and open the file as root.

baig 11-27-2008 10:41 AM

vim /etc/hosts

and then when you are done with editing ...


hit escape button for two times

and the type

:wq

to save and exit!!

Cheers!!


All times are GMT -5. The time now is 03:29 AM.