Websterz Technology Blog

Free tutorials, Tech News, Source codes, Tweaks and Tips.

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 :
  • server.websterz.net
  • 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 server.websterz.net
  • 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 server.websterz.net --static
  • Now verify the changes :
    hostnamectl status

    , should return your new hostname

  • server.websterz.net

That is all =)

Spread the love
See also  MySQL instant commands - Repair, Analyze, Optimize