LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-14-2008, 01:20 PM   #1
Rush_898
Member
 
Registered: Mar 2004
Distribution: debian...
Posts: 31

Rep: Reputation: 16
CentOS 4.4 Changing hostname Problem


The specific hostnames have been changed for your protection .


I have changed the 3 locations I know for a redhat host. Here are some results on this system:
Quote:
$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.x.x.x NEWhostname.site.domain NEWhostname
192.x.x.x NEWhostname.site.domain NEWhostname

$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME="NEWhostname"
GATEWAY=x.x.x.1

$ cat /etc/hostname
NEWhostname.site.domain
All that is set to the NEWhostname, however the command "hostname" returns the old hostname. I have tried restaring multiple times. If I manually run the command "hostname NEWHOST" and I run "hostname" it will return correctly "NEWHOST". However, my prompt does not change and when I reboot it reverts to OLDhostname.

Quote:
$ hostname
OLDhostname.storefinancial.net

Distro info:

me@OLDhostname ~ $ cat /etc/issue
CentOS release 4.4 (Final)
Kernel \r on an \m



I hope there is a simple fix I am missing, as I am quite confused. Thanks for any help.

Last edited by Rush_898; 04-14-2008 at 01:21 PM.
 
Old 04-14-2008, 01:23 PM   #2
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548

Rep: Reputation: 33
Once you reboot the new hostname will show up.
You only had to change the /etc/sysconfig/network file and that does it. Hosts file still needs updated though.

To change the hostname for this session without rebooting do a:
hostname newhostname.fully.qualified.name.com

That works until the machine is rebooted. But once rebooted it will pick up the name from the /etc/sysconfig/network file. So you'll be good to go.
 
Old 04-14-2008, 01:48 PM   #3
Rush_898
Member
 
Registered: Mar 2004
Distribution: debian...
Posts: 31

Original Poster
Rep: Reputation: 16
As god is my witness that is not working. This is my /etc/sysconfig/network file:

NETWORKING=yes
HOSTNAME=nagios001
GATEWAY=10.x.x.x


When I reboot it is the same old hostname is was before, but now I have no idea where it could even be pulling it from. I wish I was making this up.
 
Old 04-14-2008, 02:12 PM   #4
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548

Rep: Reputation: 33
Can you set the hostname via the command line:
hostname newhostname

Does that work?
 
Old 04-14-2008, 02:14 PM   #5
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548

Rep: Reputation: 33
Warning, silly question coming .......

How do you know it's the same old hostname ...in otherwords where do you see the old hostname? It's not in your prompt or something like that is it?
 
Old 04-14-2008, 02:19 PM   #6
Rush_898
Member
 
Registered: Mar 2004
Distribution: debian...
Posts: 31

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by DotHQ View Post
Warning, silly question coming .......

How do you know it's the same old hostname ...in otherwords where do you see the old hostname? It's not in your prompt or something like that is it?
Yes, the old hostname shows up as my prompt, and when I do a "hostname" command after a reboot it is the old FQDN. Where it is getting it from I do not know.


The "hostname NEWHOST" command will not change my prompt, but if I issue it and then just "hostname" it does show the correct NEWhostname. It does not however persist through a reboot.

I appreciate your help.

I tried this as well:

echo "newhost" > /proc/sys/kernel/hostname


but with a reboot it was unsuccessful as well.
 
Old 04-14-2008, 02:24 PM   #7
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548

Rep: Reputation: 33
I hate to go this route, but I have seen systems where, when the hostname was set via the gui you have to get back into the gui to change it. It must be hiding somewhere.
My suggestion is to go into the gui / network settings and change the hostname there. Maybe that will appease the gods. Good luck.
 
Old 04-14-2008, 03:58 PM   #8
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
Possible thoughts of change is in /etc/bashrc or /etc/rc.local

Brian
 
  


Reply



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
changing hostname arnuld Fedora 8 12-13-2007 05:28 AM
[CentOS 5] boot freezing when is setting hostname cmam Red Hat 1 09-13-2007 05:28 AM
Setting network hostname on CentOS 4.4 Pezzoni Linux - Networking 6 04-02-2007 01:04 PM
problem encountered after changing hostname thanhvn Linux - Software 6 07-08-2005 01:36 AM
changing hostname glock19 Linux - Networking 3 02-01-2002 09:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:56 AM.

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
Open Source Consulting | Domain Registration