top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to set hostname and domain name in CentOS 7?

+1 vote
857 views

We can permanently set hostname using hostnamectl set-hostname. How can we permanently set domain name in CentOS 7?
I found an article (http://unix.stackexchange.com/questions/239920/how-to-set-the-fully-qualified-hostname-on-centos-7-0 ) that recommended setting FQDN using hostnamectl. Is that the right way to set hostname and domainname at the same time using hostnamectl set-hostname command?

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

posted Apr 5, 2016 by Amit Parthsarthi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Though there should be a 'domainname' command to set it as well, though I just prefer editing /etc/hosts directly.

1 Answer

0 votes

Technically speaking one shouldn't put the hostname in /etc/hosts as it's not required so long as your DNS is working ... which it should be ...

answer Apr 5, 2016 by Sanketi Garg
Similar Questions
+1 vote

I currently have a problem with hostname and fqdn.
I use:

# cat /etc/redhat-release ; uname -r
CentOS release 6.4 (Final)
2.6.32-358.11.1.el6.centos.plus.x86_64

# hostname
srv1.devel.test.com

# grep HOSTNAME /etc/sysconfig/network
HOSTNAME=srv1.devel.test.com

# cat /etc/hostname
srv1

# cat /etc/domainname
devel.test.com

but

# hostname --fqdn
devel.test.com

As I think it should give: srv1.devel.test.com. Have you got similar problem? Any hint how to solve it?

+1 vote

I use "yum list installed" to determine if a package has been installed on centos. In particular, I was interested in the "man" program, installed with the command "yum install man".

In Centos6, if I look at the results, I see that "man" was installed. This is good.
In Centos7, if I look at the results, I see that "man-db" was installed. This is inconsistent.

The result is that the generic algorithm:

if I want package X , check the "yum list installed" output.
If X is not listed, install it, otherwise assume it's already installed.

Is there a reason for this inconsistency? The above algorithm works with most other packages.

0 votes

I am putting together a new mail server for our firm using a SuperMicro with Centos 7.0. When performed the install of the os, I put 16 gigs of memory in the wrong slots on the mother board which caused the SuperMicro to recognize 8 gigs instead of 16 gigs. When I installed Centos 7.0, this error made the swap file 8070 megs instead of what I would have expected to be a over 16000 megs.

I am using the default xfs file system on the other partitions. Is there a way to expand the swap file? If not, then is this problem sufficiently bad enough for me to start over with a new install. I do not want to start over unless I need to.

+1 vote

It seems that RHEL 7 will only support 64 bit. Is this correct, and what for Centos 7? Also the ARM info I found was the target is ARMv8 which is 64 bit, not the ARMv7 which is 32bit.

Any clarification?

...