温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Oracle Linux 7 修改 hostname

发布时间:2020-08-10 07:41:36 来源:ITPUB博客 阅读:163 作者:hai503 栏目:建站服务器
Linux修改hostname的常用操作方法是——手工在/etc/sysconfig/network中追加"HOSTNAME=xxxxx"并重启系统,这个方法在Oracle Linux 7中是不生效的。
那么在Oracle Linux 7中怎么配置hostname?
来源于:
How to Configure hostname in Oracle Linux 7 (Doc ID 2049221.1)

解决方案:
请使用如下三种方法的任意一种来修改Oracle Linux 7中的主机名
1. use hostname control utility: hsotnamectl
2. use NetworkManager command line tool: nmcli
3. edit /etc/hostname file directly (a reboot afterwards is required)

1. Use hsotnamectl which is a command-line client to systemd-hostnamed service


Get current hostname status:

[root@localhost ~]# hostnamectl status
   Static hostname: localhost.localdomain
  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


Set hostname:

[root@localhost ~]# hostnamectl set-hostname oraclelinux.oracle.com
[root@localhost ~]#


Re-login terminal session:

[root@oraclelinux ~]# hostnamectl status
   Static hostname: oraclelinux.oracle.com
  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


Check current hostname:

[root@localhost ~]# nmcli general hostname
localhost.localdomain


Modify hostname and restart ystemd-hostnamed service:

[root@localhost ~]# nmcli general hostname oraclelinux.oracle.com
[root@localhost ~]# systemctl restart systemd-hostnamed


Re-login terminal session:

[root@oraclelinux ~]# hostname
oraclelinux.oracle.com


3. Edit /etc/hostname


View current content:

[root@localhost ~]# cat /etc/hostname
localhost.localdomain


Replace file content with new hostname:

[root@localhost ~]# echo "oraclelinux.oracle.com" > /etc/hostname
[root@localhost ~]# cat /etc/hostname
oraclelinux.oracle.com


Restart system and verify:

[root@oraclelinux ~]# hostname
oraclelinux.oracle.com

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI