linux oracle hostname,How to Change hostname in Oracle Linux 7

How to Change hostname in Oracle Linux 7

发布时间:2020-08-09 05:31:08

来源:ITPUB博客

阅读:80

作者:eric0435

在Oracle Linux7中通过修改/etc/sysconfig/network这种方式并不能修改Oracle Linux 7的主机名。为了对Oracle Linux 7修改主机名,可以通过执行以下任何一种方法来实现:

1.使用主机名控制工具(hostnamectl)

2.使用网络管理命令行工具(nmcli)

3.编辑/etc/hostname文件

1.使用主机名控制工具(hostnamectl),它是systemd-hostnamed服务的命令行工具

获取当前主机名:

[root@jytest ~]# hostnamectl status

Static hostname: jytest

Icon name: computer

Chassis: n/a

Machine ID: 66203d1dd6f54e5da356f986ac82f473

Boot ID: e8ca08f1d73347358f085a6d0f5ed201

Virtualization: vmware

Operating System: Oracle Linux Server 7.1

CPE OS Name: cpe:/o:oracle:linux:7:1

Kernel: Linux 3.8.13-55.1.6.el7uek.x86_64

Architecture: x86_64

修改主机名:

[root@jytest ~]# hostnamectl set-hostname jytest3

重新登录获取当前主机名可以看到主机名已经变成了jytest3

[root@jytest3 ~]# hostnamectl status

Static hostname: jytest3

Icon name: computer

Chassis: n/a

Machine ID: 66203d1dd6f54e5da356f986ac82f473

Boot ID: e8ca08f1d73347358f085a6d0f5ed201

Virtualization: vmware

Operating System: Oracle Linux Server 7.1

CPE OS Name: cpe:/o:oracle:linux:7:1

Kernel: Linux 3.8.13-55.1.6.el7uek.x86_64

Architecture: x86_64

2.使用网络管理命令行工具(nmcli)

获取当前主机名

[root@jytest3 ~]# nmcli general hostname

jytest3

修改主机名并重新启动systemd-hostnamed服务

[root@jytest3 ~]# nmcli general hostname jytest2

[root@jytest3 ~]# systemctl restart systemd-hostnamed

重新登录并检查当前主机名

[root@jytest2 ~]# hostname

jytest2

3.编辑/etc/hostname文件

获取当前主机名

[root@jytest2 ~]# cat /etc/hostname

jytest2

修改主机名

[root@jytest2 ~]# echo "jytest1" > /etc/hostname

[root@jytest2 ~]# cat /etc/hostname

jytest1

重启系统并检查主机名

[root@jytest2 ~]# reboot

[root@jytest1 ~]# hostname

jytest1

[root@jytest1 ~]# cat /etc/hostname

jytest1

引用:How to Configure hostname in Oracle Linux 7 (Doc ID 2049221.1)

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值