CentOS 7 Fast Set host name Directive Hostnamectl Introduction

Source: Internet
Author: User
Tags centos

A new HOSTNAMECTL directive is added to the CENTOS7 on the host name change, which is more convenient both in terms of output and change. Take a look at hostname help information:

The code is as follows Copy Code

[Root@361way ~]# Hostnamectl--help
Hostnamectl [OPTIONS ...] COMMAND ...
Query or change system hostname.
-H--help Show this Help
--version Show Package version
--transient only set transient hostname
--static only set static hostname
--pretty only set pretty hostname
-P--privileged acquire privileges before execution
--no-ask-password don't prompt for password
-H--host=[user@]host Operate on remote host
Commands:
Status Show current hostname settings
Set-hostname NAME Set System hostname
Set-icon-name name Set icon name for host
Set-chassis NAME Set chassis type for host


View hostname information

[root@361way ~]# hostnamectl
   Static hostname:361way
  & nbsp;      Icon name:computer-desktop
            chassis:desktop
        Machine ID: 6917731f5fe447d0bca296ed2802e250
           Boot ID: E0d20bc2a3a4474c960394967d33ab53
  Operating system:centos Linux 7 (Core)
        CPE OS name:cpe:/o:centos:centos:7
            Kernel:linux 3.10.0-123.6.3.el7.x86_64
      architecture:x86_64
Set host name

As you can see from the help above, there are four host names involved in setting the hostname, as described and explained in the Hostnamectl Man Manual, as follows:

  code is as follows copy code
This tool distinguishes three different hostnames:the high-level "pretty" hostname which might include all kinds of speci Al characters (e.g. Lennart ' s
Laptop "), the static hostname which is used to initialize the kernel hostname at boot (e.g." lennarts-laptop "), and the TR Ansient hostname which might be
Assigned temporarily due to network configuration and might revert back to the "static hostname if network connectivity is Lost and is only temporarily
Written to the kernel hostname (e.g. "dhcp-47-11").
Note this pretty hostname has little restrictions on the characters used, while the static and transient hostnames Limited to the usually accepted
Characters of Internet domain names.


Change host Name

In general, the changes are made using Set-hostname:

The code is as follows Copy Code
[Root@361way ~]# hostnamectl set-hostname Blog



Changing the hostname typically involves/etc/hostname,/etc/machine-info two files, and is also explained in the man manual for different name modifications:

The static hostname is stored in/etc/hostname, and the hostname (5) For more information. The pretty hostname, chassis type, and icon name are stored in/etc/machine-info, in the Machine-id (5).

Set-icon-name settings of the host general and graphical interface will be used, the corresponding HOSTNAMECTL output icon name, Set-chassis specified the host platform type, such as the machine is desktop, can also be set to: "Desktop", " Laptop "," server "," tablet "," handset "

Related Article

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.