How to change hostname in RHEL 8?
A hostname is a name or network identity of devices connected to the computer network. There are two commands available for getting the hostname of a server or a Linux machine . They are,
1. hostname
2. hostnamectl

Example:
Code:
$ hostname
devopsrun-linux

For detailed information,
Code:
$ hostnamectl
   Static hostname: devopsrun-linux
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 7f323cb1c65f4f4a8e1d9bea6c6598fb
           Boot ID: cf4be5ad8fbf4127996115ec04461c31
    Virtualization: xen
  Operating System: Red Hat Enterprise Linux 8.0 (Ootpa)
       CPE OS Name: cpe:/o:redhat:enterprise_linux:8.0:GA
            Kernel: Linux 4.18.0-80.4.2.el8_0.x86_64
      Architecture: x86-64

How to change hostname in RHEL8/RedHat Linux 8?
The command to set hostname in linux permanently:
Code:
sudo hostnamectl set-hostname YourNewHostName

Example:
Code:
$ sudo hostnamectl set-hostname devopsrun
[admin@devopsrun-linux ~]$
[admin@devopsrun-linux ~]$ hostname
devopsrun

This change will reflect immediately and for the current shell logout and login.
Example:
Code:
[admin@devopsrun-linux ~]$ logout
[dev@devopsrun-linux ~]$ sudo su - admin
Last login: Tue Sep 07 07:58:31 UTC 2019 on pts/0
[admin@devopsrun ~]$
[admin@devopsrun ~]$
[admin@devopsrun ~]$ hostnamectl
   Static hostname: devopsrun
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 7f323cb1c65f4f4a8e1d9bea6c6598fb
           Boot ID: cf4be5ad8fbf4127996115ec04461c31
    Virtualization: xen
  Operating System: Red Hat Enterprise Linux 8.0 (Ootpa)
       CPE OS Name: cpe:/o:redhat:enterprise_linux:8.0:GA
            Kernel: Linux 4.18.0-80.4.2.el8_0.x86_64
      Architecture: x86-64