LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-04-2004, 03:37 AM   #1
oldoldcat
LQ Newbie
 
Registered: Jan 2004
Posts: 11

Rep: Reputation: 0
How to change hostname


I changed my hostname from localhost to a different name by accident when I was playing the network configuration using X Window. Now I don't know how to change it back to localhost. I can change at command line by typing "hostname localhost". But next time I start my comupter it goes back to that name I created. What do I do to change it permanently? I have only one line in my /etc/hosts file, which is "127.0.0.1 localhost.localdomain localhost". Thanks.
 
Old 02-04-2004, 04:52 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,135

Rep: Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978
Assigning localhost as a hostname is just a default. localhost resolves to the the local loopback interface i.e. 127.0.0.1 on every TCP/IP configured PC. IMO you do not want to keep the hostname as localhost.

However, you can change the hostname by editing the /etc/sysconfig/network file.
 
Old 02-04-2004, 06:47 AM   #3
oldoldcat
LQ Newbie
 
Registered: Jan 2004
Posts: 11

Original Poster
Rep: Reputation: 0
IMO? Why don't I want to keep it as localhost? What name should I use then? Thanks.
 
Old 02-04-2004, 06:51 AM   #4
LinuxLala
Senior Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: Fedora 7
Posts: 1,305

Rep: Reputation: 45
if you just do as root
hostname newhostname

That should change ur hostname. But, I don't think then you have to modify any file.
 
Old 02-04-2004, 11:27 AM   #5
oldoldcat
LQ Newbie
 
Registered: Jan 2004
Posts: 11

Original Poster
Rep: Reputation: 0
That only changes it temporarily. Like I said in my post, next time I start my computer, it goes back to the old hostname.
 
Old 02-04-2004, 12:25 PM   #6
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
look in the startup scipts, search for were the comand hostname is given then change whatever name it has
 
Old 02-05-2004, 12:25 AM   #7
oldoldcat
LQ Newbie
 
Registered: Jan 2004
Posts: 11

Original Poster
Rep: Reputation: 0
Where are startup scripts?
 
Old 02-05-2004, 12:30 AM   #8
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 47
you can add the name to the line in /etc/hosts that you mentioned, e.g.,

127.0.0.1 localhost.localdomain localhost fooname

then do "hostname fooname" as root as LinuxLala said.
 
Old 02-05-2004, 01:00 AM   #9
oldoldcat
LQ Newbie
 
Registered: Jan 2004
Posts: 11

Original Poster
Rep: Reputation: 0
Michaelk was right. I modified /etc/sysconfig/network file and the hostname is changed. If you can see this post, can you tell me why I don't want to keep localhost as the host name? Thanks.
 
Old 02-05-2004, 12:35 PM   #10
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
its ur pick, hostname is basicaly the naem of your computer, so call it whatever u want, if you want to call it localhost then u can call it that, call it whatever you want, whatever makes u happy (i wonder if anyone ever changed there hsotname to a girls name and put a picture of her as teh background in x, that would be weird)
 
Old 02-05-2004, 02:02 PM   #11
oldoldcat
LQ Newbie
 
Registered: Jan 2004
Posts: 11

Original Poster
Rep: Reputation: 0
Why would that be weird? It sounds OK to me. I didn't want to change my hostname 'cause if i change that I got to change a lot of other things. Otherwise the system won't work right. It will give me error messages, or mysql server won't start. Maybe all of this is because I'm new and don't really understand the system.
 
Old 02-05-2004, 09:20 PM   #12
maillion
Member
 
Registered: Jan 2004
Location: Texas, USA, Terra
Distribution: Debian (currently...)
Posts: 74

Rep: Reputation: 15
Quote:
Originally posted by oldoldcat
Why would that be weird? It sounds OK to me. I didn't want to change my hostname 'cause if i change that I got to change a lot of other things. Otherwise the system won't work right. It will give me error messages, or mysql server won't start. Maybe all of this is because I'm new and don't really understand the system.
I don't know either. Mine used to be my daughter's name, and I used her picture for wallpaper often. I just changed from Mandrake to Debian, and now I call the local host "golem" (from an old silent movie). I am not sure how many have fixed local host names, but most of the stuff I use look for the current host name...
 
Old 02-06-2004, 12:08 AM   #13
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Rep: Reputation: 30
What affect does changing your hostname once your have setup and configured your system under another? Will applications simply adapt to the new hostname?
 
Old 02-06-2004, 12:31 AM   #14
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
I would think most applications would use the $HOST variable instead of a specific hostname. I'm not certain of this, but I don't see why they wouldn't...this way any application that needs to use your hostname can just call the variable and it'll get whatever you've set as $HOST
 
Old 02-06-2004, 12:48 AM   #15
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Rep: Reputation: 30
Now that I've thought it through, that does seem about right. Thanks milkshaw
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you change your hostname? Thaidog Linux - Newbie 6 07-24-2005 09:52 PM
Change hostname garlam Slackware 2 10-13-2004 03:19 AM
How to change hostname blackbart Linux - Newbie 2 02-01-2004 03:56 PM
change hostname dincer80 Linux - Networking 3 07-31-2003 02:30 AM
change hostname kafnir Linux - Networking 1 10-21-2002 12:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:42 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration