Linux – RHEL, Change Host and Domain Name

linuxredhatrhel6rhel7

I want to change the Hostname and Domain Name of the Server without using yast because in this there is no yast or yast2. So please provide me the command for changes this.

I am using Red Hat Enterprise Linux Server release 6.8.

Best Answer

You may need to do several things to change the hostname (some or all of the below depending...)

Edit /etc/sysconfig/network and see if there is a HOSTNAME= directive, change as appropriate e.g.

HOSTNAME=ex1.example.com

Issue a hostname command as root e.g.

hostname ex1.example.com 

Then restart networking

/etc/init.d/network restart

You should also take a look at /etc/hosts and see if anything there needs tweaking.