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