LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to change hostname (https://www.linuxquestions.org/questions/linux-general-1/how-to-change-hostname-142100/)

oldoldcat 02-04-2004 03:37 AM

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.

michaelk 02-04-2004 04:52 AM

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.

oldoldcat 02-04-2004 06:47 AM

IMO? Why don't I want to keep it as localhost? What name should I use then? Thanks.

LinuxLala 02-04-2004 06:51 AM

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.

oldoldcat 02-04-2004 11:27 AM

That only changes it temporarily. Like I said in my post, next time I start my computer, it goes back to the old hostname.

SciYro 02-04-2004 12:25 PM

look in the startup scipts, search for were the comand hostname is given then change whatever name it has

oldoldcat 02-05-2004 12:25 AM

Where are startup scripts?

synaptical 02-05-2004 12:30 AM

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.

oldoldcat 02-05-2004 01:00 AM

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.

SciYro 02-05-2004 12:35 PM

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)

oldoldcat 02-05-2004 02:02 PM

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.

maillion 02-05-2004 09:20 PM

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...:cool:

Kristijan 02-06-2004 12:08 AM

What affect does changing your hostname once your have setup and configured your system under another? Will applications simply adapt to the new hostname?

mikshaw 02-06-2004 12:31 AM

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

Kristijan 02-06-2004 12:48 AM

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


All times are GMT -5. The time now is 06:42 AM.