博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Centos 修改主机名称
阅读量:4341 次
发布时间:2019-06-07

本文共 1666 字,大约阅读时间需要 5 分钟。

 Centos 配置主机名称:

 

1.首先查询一下当前的主机名称

[root@localhost~]# hostnamectl status   Static hostname: ******          //永久主机名   Pretty hostname: [******]          //临时主机名         Icon name: computer-server           Chassis: server        Machine ID: c141adc566834695aa95ee72f48a48d4           Boot ID: 868413124b9c4bdb8f0f8831be9a82d9  Operating System: CentOS Linux 7 (Core)       CPE OS Name: cpe:/o:centos:centos:7            Kernel: Linux 3.10.0-514.el7.x86_64      Architecture: x86-64

 

2.Centos 6修改主机名的方法

[root@localhost ~]# vim /etc/sysconfig/network        //# 编辑network文件修改hostname行(重启生效) [root@localhost ~]# cat /etc/sysconfig/network # Created by anaconda  HOSTNAME=master

 

3.Centos 7修改主机名的方法

[root@localhost ~]# hostnamectl set-hostname [master]          //修改临时主机名(立即生效)[root@master ~]# hostnamectl --static set-hostname master          //修改永久主机名(立即生效)[root@master ~]# hostnamectl status   Static hostname: master   Pretty hostname: [master]         Icon name: computer-server           Chassis: server        Machine ID: c141adc566834695aa95ee72f48a48d4           Boot ID: 868413124b9c4bdb8f0f8831be9a82d9  Operating System: CentOS Linux 7 (Core)       CPE OS Name: cpe:/o:centos:centos:7            Kernel: Linux 3.10.0-514.el7.x86_64      Architecture: x86-64

 

4.配置/etc/hosts文件名

[root@master ~]# vim /etc/hosts           //为hosts文件127.0.0.1添加hostname[root@master ~]# cat /etc/hosts 内网IP master  127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4  ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

 

5.修改完主机名后如果[root@localhost ~]#这一部分不刷新的话请关闭命令窗口重启命令窗口。Centos 6 和 7一样

 

转载于:https://www.cnblogs.com/zhaosongbin/p/8488909.html

你可能感兴趣的文章
Ecust OJ
查看>>
P3384 【模板】树链剖分
查看>>
Thrift源码分析(二)-- 协议和编解码
查看>>
考勤系统之计算工作小时数
查看>>
4.1 分解条件式
查看>>
Equivalent Strings
查看>>
flume handler
查看>>
收藏其他博客园主写的代码,学习加自用。先表示感谢!!!
查看>>
H5 表单标签
查看>>
C语言编程-9_4 字符统计
查看>>
在webconfig中写好连接后,在程序中如何调用?
查看>>
限制用户不能删除SharePoint列表中的条目(项目)
查看>>
feign调用spring clound eureka 注册中心服务
查看>>
ZT:Linux上安装JDK,最准确
查看>>
LimeJS指南3
查看>>
关于C++ const成员的一些细节
查看>>
《代码大全》学习摘要(五)软件构建中的设计(下)
查看>>
C#检测驱动是否安装的问题
查看>>
web-4. 装饰页面的图像
查看>>
微信测试账户
查看>>