修改hostname

Ubuntu 主机名存放在 /etc/hostname 文件中
vim /etc/hostname

Fedora 主机名存放在 /etc/sysconfig/network 文件中
vim /etc/sysconfig/network

/etc/hosts


修改主机名为www
1.永久性更改:vim /etc/sysconfig/network

# Created by cloud-init on instance boot automatically, do not edit.
NETWORKING=yes
HOSTNAME=www

使用 hostnamectl status 来查看主机名的状态:

[root@VM_0_11_centos ~]# hostnamectl status
   Static hostname: VM_0_11_centos
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 0ea734564f9a4e2881b866b82d679dfc
           Boot ID: 1180627a6ff343f8b6a2622724cb1e5b
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-957.21.3.el7.x86_64
      Architecture: x86-64
[root@VM_0_11_centos ~]# hostnamectl status --static
VM_0_11_centos
[root@VM_0_11_centos ~]# hostnamectl status --transient
VM_0_11_centos
[root@VM_0_11_centos ~]# hostnamectl status --pretty
VM_0_11_centos
cetos7需要用以下方式永久设置hostname
[root@VM_0_11_centos ~]# hostnamectl --static set-hostname "michael"

2.临时性更改 echo michael >/proc/sys/kernel/hostname

3.临时性更改 sysctl kernel.hostname=michael

4.临时性更改 hostname michael

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值