We help IT Professionals succeed at work.

How to change the hostname in RHEL5

Ashraf-Hassan
Ashraf-Hassan used Ask the Experts™
on
I have a server with Red Hat 5.4, and I want to change its hostname, can someone guide me how to do so, and which files to modify?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Edit /etc/sysconfig/network I think it is.  There should be a hostname= line in there.
You will need to restart network services and possibly reboot for it to take total effect.

Author

Commented:
I need to change only this file?

Commented:
look @
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-ethX
/etc/hosts

Commented:
Yes, normally that is all that is required.  This is where the HOSTNAME environment variable is set from which is what gets referenced to determine the hostname elsewhere.

Commented:
If you want to change it without rebooting, type:

# hostname -v your.new.hostname
Distinguished Expert 2017
Commented:
the correct way is to use the sys-unconfig.
Upon reboot, you will be prompted for information about the system as it is seen as being used for the first time.  No data is lost.
manually you would have to make sure to update all the various configuration files.
Commented:
You can also run system-config-network if you're able to use GUI utilities and change the hostname within there.
Top Expert 2010

Commented:
/etc/hosts

file