LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-27-2008, 01:48 AM   #1
kbklinux
LQ Newbie
 
Registered: Nov 2008
Posts: 5

Rep: Reputation: 0
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
 
Old 11-27-2008, 02:00 AM   #2
roy_lt_69
Member
 
Registered: Aug 2006
Location: Vancouver, BC, Canada
Distribution: Slackware, Bodhi, Mepis, AntiX, Mint
Posts: 172

Rep: Reputation: 21
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)!
 
Old 11-27-2008, 02:02 AM   #3
jiobo
Member
 
Registered: Nov 2008
Posts: 180

Rep: Reputation: 36
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>".
 
Old 11-27-2008, 02:06 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
... and take a copy first in case you make a mistake in the editor.
 
Old 11-27-2008, 08:24 AM   #5
kbklinux
LQ Newbie
 
Registered: Nov 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Thank You all... Yes iam talking about /etc/host file only..

Thank You
Bala
 
Old 11-27-2008, 10:36 AM   #6
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,054

Rep: Reputation: 83
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.
 
Old 11-27-2008, 10:41 AM   #7
baig
Member
 
Registered: Nov 2008
Location: وادی ھنزہ
Distribution: Solaris 5.10, Debian Server 5.2, CentOS 5.6
Posts: 226
Blog Entries: 3

Rep: Reputation: 38
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!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to edit a HTML file in linux shaiful Linux - Newbie 11 11-24-2008 12:36 PM
how to edit remote file on linux ? kapilbajpai88 Linux - Newbie 5 09-05-2008 09:54 AM
help to edit Edit my bootloader's config file from kernel prompt jagdishpandey Linux - Kernel 5 07-03-2007 06:59 AM
How to edit /boot/grub/menu.lst of the host satimis Linux From Scratch 1 09-25-2005 07:21 AM
Startup file on debian linux x86_64, looking to edit Wolvenmoon Linux - Software 1 08-19-2005 09:29 AM


All times are GMT -5. The time now is 11:14 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration