This article hasn't been updated for over 5 years. The information below may be obsolete.

How to change hostname in RHEL

This is a simple post with the offical method of changing the hostname on a Red Hat Enperprise Linux (RHEL) system.

RHEL 6.x (local server)

  • Change the hostname by editing /etc/syconfig/network
  • Change the IP address (if required) in /etc/hosts

RHEL 7.x (local server)

  • Use the hostnamectl command to change the hostname. For example:
    root@rhel7# hostnamectl set-hostname hostname
    

RHEL 7.x (remote server)

  • To change the hostname on a remote system use the hostnamectl command with the -H option. For example, to set the hostname to bravo on a remote server with IP address 192.168.2.24, we can use the following command:
    root@rhel7# hostnamectl set-hostname bravo -H root@192.168.2.24

For more information on using hostnamectl review hostnamectl(1) Linux manual page.