Change Host Name of Linux Red Hat or CentOS Permanently

Here is the short commands to change the host name of your linux Red Hat or CentOS 5 & 6 operating system, Follow the below steps:

  • Login to your server via SSH
  • Edit the file /etc/sysconfig/network by executing below command:
  • nano /etc/sysconfig/network
  • Find the host name line, usually written as :
  • Just change the host name and press:
  • CTRL + O and then press Enter

  • Now exit to the nano editor by pressing :
  • CTRL + X
  • and then execute following below command from main SSH:
  • hostname
  • It will change your hostname permanently.
  • Reboot your system by:
  • reboot

For CENTOS 7, following these steps:

  • Login to the server with root access
  • To see current hostname, execute following command :
    hostnamectl status
  • To change, execute following command :
    hostnamectl set-hostname --static
  • Now verify the changes :
    hostnamectl status

    , should return your new hostname


That is all =)