Modify the Host Name and Centos Host Name

Source: Internet
Author: User

Modify the Host Name and Centos Host Name

Centos configuration Host Name:

 

1. First query the current host name

[Root @ localhost ~] # Hostnamectl status Static hostname: ****** // permanent host name Pretty hostname: [*******] // temporary host name Icon name: computer-server Chassis: server Machine ID: c141adc56682135aa95ee72f48a48d4 Boot ID: running Operating System: CentOS Linux 7 (Core) cpe OS Name: cpe:/o: centos: 7 Kernel: Linux 3.10.0-514. el7.x86 _ 64 Architecture: x86-64

 

2. How to modify the host name in Centos 6

[Root @ localhost ~] # Vim/etc/sysconfig/network // # edit the hostname line of the network file (restart to take effect)
[Root @ localhost ~] # Cat/etc/sysconfig/network
# Created by anaconda
HOSTNAME = dch_mastar

 

3. How to modify the host name in Centos 7

[Root @ localhost ~] # Hostnamectl set-hostname [dch_mastar] // modify the temporary host name (effective immediately) [root @ dch_mastar ~] # Hostnamectl -- static set-hostname dch_mastar // modify the permanent host name (effective immediately) [root @ dch_mastar ~] # Hostnamectl status Static hostname: dch_mastar Pretty hostname: [dch_mastar] Icon name: computer-server Chassis: server Machine ID: your Boot ID: your Operating System: CentOS Linux 7 (Core) cpe OS Name: cpe:/o: centos: 7 Kernel: Linux 3.10.0-514. el7.x86 _ 64 Architecture: x86-64

 

4. Configure the/etc/hosts file name

[Root @ dch_mastar ~] # Vim/etc/hosts // Add the hostname [root @ dch_mastar ~] for the hosts file 127.0.0.1 # Cat/etc/hosts 127.0.0.1 localhost. localdomain localhost4 localhost4.localdomain4 dch_mastar: 1 localhost. localdomain localhost6 localhost6.localdomain6

 

5. After modifying the host name, if [root @ localhost ~] # If this part is not refreshed, close the command window and restart the command window. Same as Centos 6 and 7

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.