大漠驼铃

置身浩瀚的沙漠,方向最为重要,希望此blog能向大漠驼铃一样,给我方向和指引。
Java,Php,Shell,Python,服务器运维,大数据,SEO, 网站开发、运维,云服务技术支持,IM服务供应商, FreeSwitch搭建,技术支持等. 技术讨论QQ群:428622099
随笔 - 238, 文章 - 3, 评论 - 117, 引用 - 0
数据加载中……

CentOS7 修改Hostname

最近想修改Centos7的hostname, 可是如果直接修改hostname文件不生效,今天查了查原来centos有几种hostname.

 hostnamectl  控制整个系统的hostname,推荐使用
nmtul             使用text ui 控制 
nmtcli            可以用但是不推荐使用

[root@willweb ~]# hostnamectl status
   Static hostname: willweb
         Icon name: computer-vm
           Chassis: vm
        Machine ID: f9d400c5e1e8c3a8209e990d887d4ac1
           Boot ID: dd7be45d652849dcb82493c286c69dbf
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.el7.x86_64
      Architecture: x86-64
[root@willweb ~]# hostname
willweb
[root@willweb ~]# hostnamectl
   Static hostname: willweb
         Icon name: computer-vm
           Chassis: vm
        Machine ID: f9d400c5e1e8c3a8209e990d887d4ac1
           Boot ID: dd7be45d652849dcb82493c286c69dbf
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.el7.x86_64
      Architecture: x86-64
[root@willweb ~]# hostnamectl status
   Static hostname: willweb
         Icon name: computer-vm
           Chassis: vm
        Machine ID: f9d400c5e1e8c3a8209e990d887d4ac1
           Boot ID: dd7be45d652849dcb82493c286c69dbf
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.el7.x86_64
      Architecture: x86-64
使用命令如下
# hostnamectl set-hostname Your-New-Host-Name-Here
# hostnamectl set-hostname "Your New Host Name Here" --pretty
# hostnamectl set-hostname Your-New-Host-Name-Here --static
# hostnamectl set-hostname Your-New-Host-Name-Here --transient
远程设置hostname
ssh root@server-ip-here hostnamectl set-hostname server1
hostnamectl set-hostname server1 -H root@192.168.1.42





posted on 2016-11-10 09:52 草原上的骆驼 阅读(2782) 评论(0)  编辑  收藏 所属分类: Linux


只有注册用户登录后才能发表评论。


网站导航: