前言:
此刻朋友们对“centos6配置过程”可能比较关心,小伙伴们都想要分析一些“centos6配置过程”的相关资讯。那么小编同时在网摘上网罗了一些对于“centos6配置过程””的相关资讯,希望姐妹们能喜欢,同学们快快来了解一下吧!查看主机名
方式一
echo @HOSTNAME 或者hostname
方式二
hostnamectl
[root@localhost ~]# hostnamectlStatic hostname: localhost.localdomainTransient hostname: localhostIcon name: computer-vmChassis: vmMachine ID: f5b4422ae39d4e5ab2e0fc32018cc6feBoot ID: f44ad9cf36b84812b4ab0956d1a3216dVirtualization: vmwareOperating System: CentOS Linux 7 (Core)CPE OS Name: cpe:/o:centos:centos:7Kernel: Linux 3.10.0-1160.90.1.el7.x86_64Architecture: x86-64[root@localhost ~]#
其中:
Static hostname,静态主机名
Transient hostname,临时主机名
查看静态主机名用hostnamectl,查看临时主机名用hostname
修改主机名
修改主机名需要两步:
1. 修改主机名
2. 修改下/etc/hosts中的对应关系
特别说明下:
修改主机名后,如果不修改/etc/hosts中的对应关系,从本地ping 主机名的时候会ping主机的外网地址,修改后,ping的是127.0.0.1.解析的过程会快一些
修改前:
[root@combo73 ~]# ping combo73PING combo73 (192.168.0.73) 56(84) bytes of data.64 bytes from localhost (192.168.0.73): icmp_seq=1 ttl=64 time=0.041 ms64 bytes from localhost (192.168.0.73): icmp_seq=2 ttl=64 time=0.043 ms64 bytes from localhost (192.168.0.73): icmp_seq=3 ttl=64 time=0.062 ms64 bytes from localhost (192.168.0.73): icmp_seq=4 ttl=64 time=0.061 ms64 bytes from localhost (192.168.0.73): icmp_seq=5 ttl=64 time=0.056 ms64 bytes from localhost (192.168.0.73): icmp_seq=6 ttl=64 time=0.064 ms64 bytes from localhost (192.168.0.73): icmp_seq=7 ttl=64 time=0.058 ms64 bytes from localhost (192.168.0.73): icmp_seq=8 ttl=64 time=0.058 ms64 bytes from localhost (192.168.0.73): icmp_seq=9 ttl=64 time=0.627 ms64 bytes from localhost (192.168.0.73): icmp_seq=10 ttl=64 time=0.058 ms64 bytes from localhost (192.168.0.73): icmp_seq=11 ttl=64 time=0.094 ms64 bytes from localhost (192.168.0.73): icmp_seq=12 ttl=64 time=0.064 ms64 bytes from localhost (192.168.0.73): icmp_seq=13 ttl=64 time=0.056 ms64 bytes from localhost (192.168.0.73): icmp_seq=14 ttl=64 time=0.062 ms64 bytes from localhost (192.168.0.73): icmp_seq=15 ttl=64 time=0.057 ms64 bytes from localhost (192.168.0.73): icmp_seq=16 ttl=64 time=0.054 ms64 bytes from localhost (192.168.0.73): icmp_seq=17 ttl=64 time=0.087 ms64 bytes from localhost (192.168.0.73): icmp_seq=18 ttl=64 time=0.071 ms64 bytes from localhost (192.168.0.73): icmp_seq=19 ttl=64 time=0.068 ms64 bytes from localhost (192.168.0.73): icmp_seq=20 ttl=64 time=0.066 ms64 bytes from localhost (192.168.0.73): icmp_seq=21 ttl=64 time=0.053 ms^C--- combo73 ping statistics ---21 packets transmitted, 21 received, 0% packet loss, time 24161msrtt min/avg/max/mdev = 0.041/0.088/0.627/0.121 ms
修改后:
[root@combo73 ~]# ping combo73PING combo73 (127.0.0.1) 56(84) bytes of data.64 bytes from combo73 (127.0.0.1): icmp_seq=1 ttl=64 time=0.029 ms64 bytes from combo73 (127.0.0.1): icmp_seq=2 ttl=64 time=0.058 ms64 bytes from combo73 (127.0.0.1): icmp_seq=3 ttl=64 time=0.059 ms64 bytes from combo73 (127.0.0.1): icmp_seq=4 ttl=64 time=0.046 ms64 bytes from combo73 (127.0.0.1): icmp_seq=5 ttl=64 time=0.057 ms64 bytes from combo73 (127.0.0.1): icmp_seq=6 ttl=64 time=0.053 ms64 bytes from combo73 (127.0.0.1): icmp_seq=7 ttl=64 time=0.053 ms64 bytes from combo73 (127.0.0.1): icmp_seq=8 ttl=64 time=0.054 ms64 bytes from combo73 (127.0.0.1): icmp_seq=9 ttl=64 time=0.053 ms64 bytes from combo73 (127.0.0.1): icmp_seq=10 ttl=64 time=0.046 ms64 bytes from combo73 (127.0.0.1): icmp_seq=11 ttl=64 time=0.045 ms64 bytes from combo73 (127.0.0.1): icmp_seq=12 ttl=64 time=0.055 ms64 bytes from combo73 (127.0.0.1): icmp_seq=13 ttl=64 time=0.054 ms64 bytes from combo73 (127.0.0.1): icmp_seq=14 ttl=64 time=0.062 ms64 bytes from combo73 (127.0.0.1): icmp_seq=15 ttl=64 time=0.148 ms64 bytes from combo73 (127.0.0.1): icmp_seq=16 ttl=64 time=0.065 ms64 bytes from combo73 (127.0.0.1): icmp_seq=17 ttl=64 time=0.057 ms64 bytes from combo73 (127.0.0.1): icmp_seq=18 ttl=64 time=0.054 ms64 bytes from combo73 (127.0.0.1): icmp_seq=19 ttl=64 time=0.058 ms64 bytes from combo73 (127.0.0.1): icmp_seq=20 ttl=64 time=0.064 ms64 bytes from combo73 (127.0.0.1): icmp_seq=21 ttl=64 time=0.104 ms^C--- combo73 ping statistics ---21 packets transmitted, 21 received, 0% packet loss, time 20030msrtt min/avg/max/mdev = 0.029/0.060/0.148/0.025 ms
hostnamectl set-hostname 新主机名
hostnamectl set-hostname combo73
[root@combo73 ~]# hostnamectlStatic hostname: combo73Icon name: computer-vmChassis: vmMachine ID: f5b4422ae39d4e5ab2e0fc32018cc6feBoot ID: f44ad9cf36b84812b4ab0956d1a3216dVirtualization: vmwareOperating System: CentOS Linux 7 (Core)CPE OS Name: cpe:/o:centos:centos:7Kernel: Linux 3.10.0-1160.90.1.el7.x86_64Architecture: x86-64
修改主机名后,可以看到临时主机名消失了
重新登录下,环境变量中的主机名和命令提示符中的主机名也改过来了
[root@combo73 ~]# echo $HOSTNAME
combo73
改下/etc/hosts中的配置
修改前:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
修改为:
127.0.0.1 combo73127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 combo73::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
版权声明:
本站文章均来自互联网搜集,如有侵犯您的权益,请联系我们删除,谢谢。
标签: #centos6配置过程