Learn how to define your system hostname on Red Hat 8 locally or remotely. Use pretty names on your system…
Redhat 8 hostnamectl Command – All system must have a hostname defined in order to be identified on the network. On Red Hat 8 we use hostnamctl command to define the system hostname, this command has a few options :
Verify System Info
First let’s check our system status and check our current hostname.
[[email protected] ~]# hostnamectl status
Define System Hostname
Now let’s define our system hostname using the command hostnamectl:
[[email protected] ~]# hostnamectl set-hostname poplab.pt
Define Pretty Hostname
Sometimes is necessary to use a hostname with strange names or symbols for that we can use the pretty parameter.
[ro[email protected] ~]# hostnamectl set-hostname "PopLab" --pretty
Clear System Hostname
To empty the hostname field just type:
[[email protected] ~]# hostnamectl set-hostname ""
Change Hostname Remotelly
If is necessary we can change the hostname on a remote machine, just type the next command:
[[email protected] ~]# hostnamectl set-hostname -H [username]@poplab
Using nmcli to define Hostname
Hostname can be changed with another tool called nmcli
[[email protected] ~]# nmcli general hostname
[[email protected] ~]# nmcli general hostname poplab.pt
Hostnamectl Set Server location
[[email protected] ~]# hostnamectl set-location HomeLAB