[CentOS] How to set hostname and domainnmae in CentOS 7?

Gregory P. Ennis PoMec at PoMec.Net
Sun Apr 10 02:19:23 UTC 2016

We can permanently set hostname using  hostnamectl set-hostname. How
can we
permanently set *domain name* in CentOS 7?
I found an article
that recommended setting FQDN using hostnamectl. Is that the right way
set hostname and domainname at the same time using *hostnamectl
set-hostname* command?

 Running *hostnamectl set-hostname* will set the hostname in*
but it doesn't change */etc/hosts*. What's the proper way of adding
hostname and FQDN to */etc/hosts *in CentOS 7?




I used the following command in the /etc/rc.d/rc.local file which is
used at boot time.

/bin/domainname Domain.com

Make sure you also use :

chmod +x /etc/rc.d/rc.local

to make sure the file is executable.


More information about the CentOS mailing list