How To Change Linux Hostname Redhat/CentOS/Fedora

In this post we are going see how can we change the host name of a Linux machine. Just follow the steps below:

  • 1- Find and edit the following file "/etc/hosts"
127.0.0.1               localhost.localdomain localhost --new_hostname--

::1             localhost6.localdomain6 localhost6
10.111.1.111 xxxx1
10.111.2.111 xxxx2
  • 2- Edit /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain   <
Save and close the file.
  • 3- Type the following command:
 hostname --your new hostname--

 hostname

 
Your new hostname should be set now.