LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Permanently change the hostname (https://www.linuxquestions.org/questions/linux-software-2/permanently-change-the-hostname-58858/)

juby 05-09-2003 12:32 AM

Permanently change the hostname
 
Hi , i want to permanently change my machine's name as linuxQube or something like that.. the hostname command onyl sets it for the current session ..when i reebot i get localhost.localdomain. I run apache, tomcat etc etc.. will chnaging m hostname affect those services ?? how can i do it "safe" :) ???

senthil 05-09-2003 01:45 AM

Hi,

Edit ur /etc/hosts file to add the hostname. Or you can use linuxconf or netconf to give the hostname.

Hope this helps.

Senthil

bm1 05-09-2003 02:35 AM

this thread helped me
http://www.linuxquestions.org/questi...threadid=57490

jharris 05-09-2003 04:42 AM

Quote:

Originally posted by senthil
Edit ur /etc/hosts file to add the hostname. Or you can use linuxconf or netconf to give the hostname.
/etc/hosts only holds a mapping between hostnames and IP addresses, it doesn't actually set anything...

cheers

Jamie...

BigNate 05-09-2003 06:03 AM

Hello!
redhat=>system settings=>network

enter root password

click "hosts" tab and enter a name!

senthil 05-09-2003 11:43 AM

Oops Sorry,

U have to set it in /etc/sysconfig/network file.

Senthil

juby 05-09-2003 12:41 PM

i tried it in rc.sysinit but apache wwebserver dint start !

fancypiper 05-09-2003 01:05 PM

Create a file /etc/hostname

Put one entry in that file, your hostname. My file:
Code:

tinwhistle
My /etc/hosts file:
Code:

# Gentoo Celeron 850 box tinwhistle /etc/hosts file
127.0.0.1      tinwhistle      localhost.localdomain  localhost
192.168.0.1    bones
192.168.0.2    tinwhistle
192.168.0.3    uilleann


jonr 05-09-2003 01:07 PM

I got so frustrated not being able to change the host name permanently, that I finally did a "slocate localhost" and then visited all the files that appeared to play a role in keeping my computer so stupidly named, and changed every instance (about four, as it turned out) to the name I wanted.

Result: name permanently changed. HOWEVER, I am not on a network, just a lone desktop with Internet access. So I would not advise this approach for anybody with a more complex setup. It could indeed be asking for trouble.

EDITED: Oops, sorry, what I did was look for the string "localhost" inside all files, using Midnight Commander's search function. Slocate would not give that information.


senthil 05-09-2003 01:35 PM

If u see /etc/rc.sysinit file, /etc/sysconfig/network file is sourced to set the hostname and then the value of /bin/hostname is read. So if you set the hostname in /etc/sysconfig/network you should be ok.

I think you should also set the ServerName in httpd.conf or think it reverts to localhost.

Senthil

juby 05-10-2003 12:23 AM

Got it fine !! tahnx all
 
i changed the etc/hosts file

as 127.0.0.1 linuxcube.localdomain linuxcube

& then the etc/sysconfig/network file's hostname = linuxcube
everything works fine ..thanx for the help !

Aussie 05-10-2003 12:46 AM

The command to set or change the system hostname is 'hostname'.
Do 'man hostname' to read the unix manual page for the hostname command.

jonr 05-10-2003 08:27 AM

Quote:

Originally posted by Aussie
The command to set or change the system hostname is 'hostname'.
Do 'man hostname' to read the unix manual page for the hostname command.

That works for changing the hostname during the session you're in, but on the next reboot, the hostname reverts to the old one. At least in the distribution I use! The question here was how to permanently change the hostname.

senthil 05-10-2003 12:34 PM

Hi,

As I told before, you have to set it in /etc/sysconfig/network. Or a hack - do hostname -v <HOSTNAME> in /etc/rc.d/rc.local file. Instead of manually setting for that boot session this does it automatically.

Cheers,
Senthil


All times are GMT -5. The time now is 10:17 PM.