
There are 2 ways of changing the Red Hat operating system hostname. You can do the changes for temporary or permanently.
Temporary Hostname:
1. Check your hostname.
# hostname oldhostname
2. Change the hostname.
# hostname newhostname
3. Verify
# hostname newhostname
Note:
The old hostname will revert back after you reboot the system.
Permanent Hostname:
1. Check your hostname.
# cat /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=oldhostname
2. Edit the /etc/sysconfig/network file & save!
# vi /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=newhostname
3. Next, edit the /etc/hosts file & save!
# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
10.0.0.10 newhostname
to
# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
10.0.0.10 newhostname
4. Restart network services.
# service xinetd restart