Latest article: Virson ' s Blog1. Temporarily modify hostname
Address: http://www.cnblogs.com/mawanglin2008/p/3530790.html
Display host Name:
[Email protected]:~$ hostnamelocalhost
Modify Host Name:
[Email protected]:~$ sudo hostname orcl1[email protected]:~$ HOSTNAMEORCL1
2. Permanently modify the host name
The above modification is only a temporary change, after the restart is back to the original.
Step 1:
Modify the hostname in/etc/sysconfig/network
Vi/etc/sysconfig/networkhostname=localhost.localdomain #修改localhost. Localdomain to ORCL1
Modify the hostname entry for the network. The point is preceded by the hostname, and the dot is followed by the domain name. No point is the host name.
This is permanently modified and takes effect after reboot. Currently I do not know how to take effect immediately.
To take effect immediately, you can use the first method at the same time.
Step 2:
Modify the/etc/hosts file
vi/etc/hosts127.0.0.1 localhost.localdomain #修改localhost. Localdomain to ORCL1
Shutdown-r now #最后, restart the server.
--------------------------------------------------------------------------------------------------------------- -----------------------------------------
Address: http://www.centoscn.com/CentOS/help/2015/0206/4640.html
Permanently modified on Edhat/centos
[Email protected] ~]# cat/etc/sysconfig/network
Networking=yes
Hostname=localhost.localdomain
gateway=192.168.10.1
Modify the hostname entry for the network. The point is preceded by the hostname, and the dot is followed by the domain name. No point is the host name.
[Email protected] ~]# vi/etc/sysconfig/network
Networking=yes
Networking_ipv6=no
Hostname=master
This is permanently modified and takes effect after reboot. Currently I do not know how to take effect immediately.
To take effect immediately, you can use the first method at the same time.
There is also a change:
/etc/hosts
127.0.0.1 Localhost.localdomain
The part behind the 127.0.0.1.
modified on Deb/ubuntu :
Hostname
Localhost.localdomain
sudo vi/etc/hostname
Fill in the/etc/hostname directly with hostname as Master
[Email protected]:~$ cat/etc/hostname
localhost
After the reboot, the prompt becomes.
[Email protected]:~$
If you do not want to restart, use the hostname name order.
3. Other modification methods
Modify Kernel.hostname with Sysctl
View:
[Email protected]:~$ sysctl kernel.hostname
Kernel.hostname = Master
Modify:
[Email protected]:~$ sudo sysctl kernel.hostname=hadoop
Kernel.hostname = Hadoop
Re-opening the shell becomes the following hostname Hadoop
[Email protected]:~$
CentOS Modify host name