Linux修改主机名

Linux修改主机名

服务器版本: Centos 7.2 参考

临时修改主机名

hostname 查看当前系统主机名,知道当前主机名
hostname 要修改的主机名

[root@i-9s7be0le ~]# hostname masteryee-one
[root@i-9s7be0le ~]# hostname
masteryee-one

永久修改主机名

当然在centos7特地添加了 hostnamectl 命令查看,修改主机名

[root@i-9s7be0le ~]# hostnamectl
   Static hostname: i-9s7be0le
Transient hostname: masteryee-one
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 668a8a15b473b53db8a06eba66cbc862
           Boot ID: b7a67567d7624913a7b25cfac8cc6bf5
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.4.5.el7.x86_64
      Architecture: x86-64

使用 hostnamectl set-hostname 命令修改主机名,可永久生效:

[root@i-9s7be0le ~]# hostnamectl set-hostname masteryee-one
[root@i-9s7be0le ~]# hostname
masteryee-one
[root@i-9s7be0le ~]# hostnamectl
   Static hostname: masteryee-one
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 668a8a15b473b53db8a06eba66cbc862
           Boot ID: b7a67567d7624913a7b25cfac8cc6bf5
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.4.5.el7.x86_64
      Architecture: x86-64
[root@i-9s7be0le ~]# 
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值