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
Release: 2023-05-18 17:37:26
forward
1901 people have browsed it

CentOS 6

1. Log in to the system remotely.

2. Use the hostname command.

hostname zhaomu.com
Copy after login

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
Copy after login

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
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template