# cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost
NTPSERVERARGS=iburst
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost
NTPSERVERARGS=iburst
# hostname
localhost.localdomain
localhost.localdomain
just edit following method
# vi /etc/hosts
127.0.0.1 changename
::1 localhost6.localdomain6 localhost6
# vi /etc/sysconfig/network
HOSTNAME=CHANGENAME
#reboot
now you can get the changed name
in case fo EC2
#hostnamectl set-hostname yourhostname
# vi /etc/cloud/cloud.cfg
//add following line to bottom of the file
preserve_hostname: true
#reboot
------------------------------------------------------------
for centos 7
[root@localhost ~]# hostnamectl status
Static hostname: localhost.localdomain
Icon name: computer-vm
Chassis: vm
Machine ID: 6c426b1abe1c4ab8996398e6dff1cd7a
Boot ID: 6a5cc86cdf224ff288b1646eb90c8747
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-514.el7.x86_64
Architecture: x86-64
127.0.0.1 changename
::1 localhost6.localdomain6 localhost6
# vi /etc/sysconfig/network
HOSTNAME=CHANGENAME
#reboot
now you can get the changed name
in case fo EC2
#hostnamectl set-hostname yourhostname
# vi /etc/cloud/cloud.cfg
//add following line to bottom of the file
preserve_hostname: true
#reboot
------------------------------------------------------------
for centos 7
[root@localhost ~]# hostnamectl status
Static hostname: localhost.localdomain
Icon name: computer-vm
Chassis: vm
Machine ID: 6c426b1abe1c4ab8996398e6dff1cd7a
Boot ID: 6a5cc86cdf224ff288b1646eb90c8747
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-514.el7.x86_64
Architecture: x86-64
or
#hostnamectl
[root@localhost ~]# hostnamectl set-hostname server.xxxxx.com
or else
go to #nmtui
and set the hostname
---------
# hostname --fqdn
rhel8_1.boobi.com
# hostname
rhel8_1.boobi.com
# dnsdomainname
boobi.com
# cat /etc/hosts
127.0.0.1 rhel8_1.boobi.com rhel8_1
#cat /etc/hostname
rhel8_1.boobi.com
----
0 Comments