LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Changing the hostname. (http://www.linuxquestions.org/questions/slackware-14/changing-the-hostname-24683/)

KrazyKid 06-30-2002 08:29 PM

Changing the hostname.
 
How do I change the hostname on my linux box from the default one. I am running Slack.

---------------------------------------------------------------------------------

Thx ,

KrazyKid.
:newbie:

crabboy 06-30-2002 08:39 PM

Change the hostname stored in the /etc/HOSTNAME file.

If you want to setup the hostname as well as other network properties, you can use the 'netconfig' script.

trickykid 06-30-2002 08:41 PM

hostname name-of-host-that-you-want

ahh.. crabboy beat me.. i never get beaten.. :cry:

SlCKB0Y 06-30-2002 08:57 PM

ummm, this is a dumb way to do it unless you also change /etc/hosts, lots of things will start not to work, but nice try guys.

Why not run hostname from the command line and it will change it all for you???

simple

trickykid 06-30-2002 09:02 PM

Actually that is what I mentioned.. just use the hostname command.. and come to think of it, the netconfig script will make the updates as well, but unfortunately there is no /etc/hostname file.. at least my Slack boxes don't have that file, never did either.. :)

that's funny and just notice, everyone's reply in this thread either ends with boy or kid.. :D

KrazyKid 06-30-2002 09:36 PM

Thx all for your help with my system.:newbie:

Excalibur 06-30-2002 09:56 PM

Well, can somebody else get in on the fun here?

Actually the proper method is to use /sbin/netconfig that was suggested earlier. If the machine is networked then it is also the best here because the machine is still using the default name of darkstar.example.net then it has not been run at all. If not, then manually changing a file is OK.

The netconfig script writes/creates several files.

/etc/HOSTNAME (note: the uppercase)
/etc/networks
/etc/resolv.conf
/etc/hosts
/etc/rc.d/rc.inet1

That is all that I can recall at the moment. HOSTNAME is the only file that doesn't pertain to networking other than it contains the fully qualified domain name for the others to use.

To change the hostname manually without the networking parts. Modify the /etc/HOSTNAME to contain the name desired and then run the command

hostname new-host-name

If the HOSTNAME file is not modified then it will revert back on the next boot because it will be read by /etc/rc.M script. To my knowledge the hostname command does not modify any files.

If the machine is networked then the /etc/hosts file must also be updated manually.

In one way or another you were all right. Please feel free to correct anything that I may be amiss.

Cheers


All times are GMT -5. The time now is 05:09 PM.