How to Change or Set hostname on OEL/RHEL/CentOS 6
We can change the hostname of the Oracle Enterprise Linux (OEL), Red Hat Linux (RHEL) or CentOS version 6 operating system by using two basic methods which using the command line or graphical interface.
Warning: Changing the hostname on a system may have unexpected effects on running network services. It is best to shut down services like Oracle and web services before changing the hostname, or better yet, make the change to the appropriate configuration files, then reboot for the change to take effect.
How to find hostname?
hostname command to find the hostname of the Linux system. For example:
# hostname schlumpf.localdomain
# grep -i hostname /etc/sysconfig/network HOSTNAME=schlumpf.localdomain
Set / Change the hostname via comand-line
- Using a text editor, open the servers
% sudo vi /etc/sysconfig/network
- Modify the
HOSTNAME=value to match your FQDN hostname (for example):
- (optional) Change the hostname that is associated with the main IP address in
- Reboot your server.
Set / Change the hostname via GUI
- Using the
system-config-networkcommand to start a text-based network configuration tool.
- Navigate using the Tab, arrow keys and Enter keys and select the
- Modify your preferred hostname and click OK.
- Reboot your server