Jump to Navigation

155 - Permanent hostname change on RedHat

RedHat based system use the file /etc/sysconfig/network to read the saved hostname at system boot.
This is set using the init script /etc/rc.d/rc.sysinit.

* Edit /etc/sysconfig/network


* After the change, restart the network server.

# service network restart   (or /etc/init.d/network restart)

So in order to preserve your change on system reboot edit this file and enter the appropriate name using the HOSTNAME
variable. Use sysctl to change the hostname.

* Edit /etc/hosts localhost.localdomain localhost server1.mydomain.com server1
#::1    localhost.localdomain   localhost       server1

* To read the current hostname

$ sysctl kernel.hostname

kernel.hostname = server0.mydomain.com

* Change the host name

$ sysctl kernel.hostname="NEW_HOSTNAME"


Main menu 2

Story | by Dr. Radut