Home >Operation and Maintenance >Linux Operation and Maintenance >How to change the hostname of Linux cloud server

How to change the hostname of Linux cloud server

PHPz
PHPzforward
2023-05-18 17:37:261941browse

CentOS 6

1. Log in to the system remotely.

2. Use the hostname command.

hostname zhaomu.com

3. Edit the /etc/hosts file. Replace the old hostname with the new hostname.

4. Edit /etc/sysconfig/network. Change the value of the HOSTNAME parameter to the new hostname.

5. Use the hostname command to check whether it takes effect.

CentOS 7/Ubuntu

1. Log in to the system remotely.

2. Use the hostnamectl command.

hostnamectl set-hostname zhaomu.com

3. Use the hostname command to check whether it takes effect.

Debian

1. Log in to the system remotely.

2. Edit the /etc/hostname file. Replace the old hostname with the new hostname.

3. Edit the /etc/hosts file. Replace the old hostname with the new hostname.

4. Execute the hostname.sh script.

/etc/init.d/hostname.sh start

5. Use the hostname command to check whether it takes effect.

The above is the detailed content of How to change the hostname of Linux cloud server. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete