Virtual Machines


Virtual Machines

Documentation > Products > Virtual Machines > Method to Modify Hostname of Linux System

Method to Modify Hostname of Linux System

There are two common methods to modify the hostname of Linux system, which is summarily described herein.

Temporarily Effective Modification

Use the command line to modify the hostname (customizable) and re-login shell to take effect.

After re-logging in, you can see that it has taken effect.

Permanently Effective Modification

Take CentOS system as an example. In order to modify the configuration file and take effect, modify the HOSTNAME=hostname (customizable) in /etc/sysconfig/network and the restart to take effect.

If it is an Ubuntu system, modify the file /etc/hostname and change its corresponding hostname to the new one.

Finally, replace the old hostname corresponding to in /etc/hosts with the new one.

Note: If it is the CentOS 7 operating system, use the command hostnamectl set-hostname to modify. After the modification, SHELL log in again.

If your problem still can not solved, please submit open ticket to us.

Update Time:2019-08-28 21:38:32