21.8 C
Guru Unix /Linux and GNU supporter

change hostname in RHEL8/Centos8

The Redhat 8 final will be relased soon ,the beta version is already  there and  ready for testing. i will show you in this tutorial how to change hostname in RHEL 8 or Centos8 Server or maybe a Work station. please  remember hostnames can contain letters digits hyphen and dot characters. and must contains between 2 and 63 characters.

1-Set Hostname on RHEL8/ Centos8

In my case i want to change my hostnamen to osradar-rhel8.local.domain.  please do it the comand hostnamectl

hostnamectl set-hostname osradar-rhel8.local.domain

- Advertisement -

1-1-Reboot The Server

command reboot to  restart


1-2-check the new  hostname now

[root@osradar-rhel8 ~]# uname -a
Linux osradar-rhel8.local.domain 4.18.0-32.el8.x86_64 #1 SMP Sat Oct 27 19:26:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@osradar-rhel8 ~]# hostnamectl
   Static hostname: osradar-rhel8.local.domain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: f64d8254a85c4fd1b37c6b4600c3eb8f
           Boot ID: a6a07a436ab747808485394f81e2bdaa
    Virtualization: oracle
  Operating System: Red Hat Enterprise Linux 8.0 Beta (Ootpa)
       CPE OS Name: cpe:/o:redhat:enterprise_linux:8.0:beta
            Kernel: Linux 4.18.0-32.el8.x86_64
      Architecture: x86-64
[root@osradar-rhel8 ~]# cat   /proc/sys/kernel/hostname
[root@osradar-rhel8 ~]# cat /etc/hostname
[root@osradar-rhel8 ~]#

Option:  you can add the hostname to  /etc/hosts

[root@osradar-rhel8 ~]# cat /etc/hosts localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 osradar-rhel8.local.domain
[root@osradar-rhel8 ~]# ping osradar-rhel8.local.domain
PING osradar-rhel8.local.domain ( 56(84) bytes of data.
64 bytes from osradar-rhel8.local.domain ( icmp_seq=1 ttl=64 time=0.052 ms
64 bytes from osradar-rhel8.local.domain ( icmp_seq=2 ttl=64 time=0.073 ms
64 bytes from osradar-rhel8.local.domain ( icmp_seq=3 ttl=64 time=0.071 ms
64 bytes from osradar-rhel8.local.domain ( icmp_seq=4 ttl=64 time=0.074 ms
64 bytes from osradar-rhel8.local.domain ( icmp_seq=5 ttl=64 time=0.075 ms

--- osradar-rhel8.local.domain ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 81ms
rtt min/avg/max/mdev = 0.052/0.069/0.075/0.008 ms
[root@osradar-rhel8 ~]#

4-Change Hostname via nmtui  Tool 

This option also easy for starters  to change the hostname using  nmtui tool

just  Type  nmtui


Then Set system Hostname

Quit and reboot your  System



Please enjoy

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"


Please enter your comment!
Please enter your name here

Latest article