Skip to content

Change hostname in Linux

Here are some methods to change hostname for a certain Linux system.

One-time Change

Side effect, ineffective after reboot

hostname {NEW host name}

Permanently Change

1 revise /etc/hosts

127.0.0.1  localhost  {NEW host name}

2 revise /etc/sysconfig/network

HOSTNAME={NEW host name}

Using hostnamectl

hostnamectl set-hostname NAME