Linux_CentOS7 configure the host name, linux_centos7

Source: Internet
Author: User

Linux_CentOS7 configure the host name, linux_centos7

Original Works are from the blog of "Deep Blue blog". You are welcome to reprint them. Please note the following source when reprinting them. Otherwise, you will be held legally liable for copyright.

Deep Blue blog: http://blog.csdn.net/huangyanlong/article/details/45476569

 

Method 1: temporarily modify the Host Name
Syntax:
# Hostname <Host Name>
Example:

[root@hyldb /]# hostname hyltest[root@hyldb /]# su -Last login: Sun May  3 17:58:30 CST 2015 on pts/1[root@hyltest ~]# 

Method 2: run the command to modify the Host Name
Syntax:
# Hostnamectl set-hostname <Host Name>

View the hostnamectl Command help
[Root @ hyldb ~] # 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 Do not 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

Example:

[root@hyltest ~]# hostnamectl set-hostname hyldb[root@hyltest ~]# su - Last login: Sun May  3 18:02:11 CST 2015 on pts/1[root@hyldb ~]# 

Method 3: manually modify the host name in the configuration file
Syntax:
Modify the hostname configuration file
Example:

[root@hyltest ~]# cd /etc[root@hyltest etc]# vi hostnamehyldb~[root@hyltest etc]# su - Last login: Sun May  3 18:03:15 CST 2015 on pts/1[root@hyldb ~]# 

Summary:

Hostnamectl-help

/Etc/hostname

 

After modifying the host name, add the host ing name to the/etc/hosts file.

[root@hyldb etc]# cat hosts127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4::1         localhost localhost.localdomain localhost6 localhost6.localdomain610.53.105.10 hyldb<span style="font-family:SimSun;font-size:14px;"></span>

Original Works are from the blog of "Deep Blue blog". You are welcome to reprint them. Please note the following source when reprinting them. Otherwise, you will be held legally liable for copyright.

Deep Blue blog: http://blog.csdn.net/huangyanlong/article/details/45476569

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.