Home  >  Article  >  Operation and Maintenance  >  How to check centos host name

How to check centos host name

WBOY
WBOYOriginal
2022-02-07 16:14:1613376browse

In centos, you can use the hostnamectl command to query the host name. The function of this command is to manage the host name. When this command does not take parameters, you can view the host name information. The syntax is "hostnamectl".

How to check centos host name

The operating environment of this article: centos 6.4 system, Dell G3 computer.

How to check the centos host name

1. Check the host name

CentOS7 uses the hostnamectl command to manage the host name. This command can be used without parameters. Check the host name information

[root@CentOS7-1 ~]# hostnamectl
   Static hostname: CentOS7-1
         Icon name: CentOS7-1
           Chassis: vm
        Machine ID: 0b269f4da7e94412992cbfa2562855be
           Boot ID: 24c06429f69048639a7e155f7d14ef87
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-862.el7.x86_64

2. Check the virtualization

In fact, this command is very powerful and you can also see the type of virtualization. For example, I am using vmware now. . Therefore, we can know through this command that

AWS uses xen

Alibaba Cloud uses kvm

JD Cloud also uses kvm

No Tencent Cloud’s host, I don’t know what it is

3. Types of host names

In CentOS7, there are three types of host names (said in the man manual, in fact There are 4 in total including icon name), namely pretty, static and transient.

pretty: can contain various special characters

static: used to initialize the kernel host name at startup. Only characters that can be used as domain names are used. This name is what we see in the terminal. Name

transient: The default temporary hostname received from the network configuration, which can only use characters that can be used as domain names

static hostname is saved in /etc/hostname, and pretty hostname and icon name is saved in /etc/machine-info

If a static hostname is set and the hostname is valid (not localhost), the temporary hostname is not used.

4. Set the host name

In addition, if you use hostnamctl set-hostname NAME, pretty will accept uppercase letters, and static will convert uppercase letters to lowercase letters. .

But what if we really want the static hostname to be capitalized? Then we can bring parameters and set

hostnamectl --pretty set-hostname TEST-name    # 设置pretty hostname
hostnamectl --static set-hostname TEST-name    # 设置static hostname
hostnamectl --transient set-hostname TEST-name    # 设置transient hostname

5 and icon name

respectively. Let's talk about the icon name. This name is mainly used in some graphical interfaces. Some desktops will read this parameter as the host name, similar to "this computer" on Windows. You can use the following command to set it

hostnamectl set-icon-name MY-comp

Recommended tutorial: "centos tutorial"

The above is the detailed content of How to check centos host name. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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