CentOS 7 Change Hostname

View Hostname:
hostnamectl status

 

Set Hostname:
hostnamectl set-hostname Your-New-Host-Name-Here
hostnamectl set-hostname "Your New Host Name Here" --pretty
hostnamectl set-hostname Your-New-Host-Name-Here --static
hostnamectl set-hostname Your-New-Host-Name-Here --transient

 

Delete Hostname:
hostnamectl set-hostname ""
hostnamectl set-hostname "" --static
hostnamectl set-hostname "" --pretty

 

Restart for changes to take:
systemctl restart systemd-hostnamed

 

Can also use nmcli to set hostname:

 

View Hostname:
nmcli general hostname

 

Change Hostname:
nmcli general hostname devel
nmcli general hostname devel.test.com

 

Restart for changes to take:
systemctl restart systemd-hostnamed

 

S5 Box

Login