在Oracle Linux7中怎么配置hostname

Oracle  Linux7中怎么配置hostname?
来源于:
How to Configure hostname in Oracle  Linux  7 (文档 ID 2049221.1)
适用于:
Linux OS - Version Oracle Linux 7.0 and later
Linux x86
Linux x86-64
目标:
本文描述了在Oracle Linux7中修改hostname的方法
注意:手工在/etc/sysconfig/network中追加"HOSTNAME=xxxxx"并重启os,这个方法在Oracle Linux7中是不生效的。
解决方案:
请使用如下三种方法的任何一种来修改Oracle Linux7中的主机名
[html]   view plain   copy
 
  1. 1. use hostname control utility: hsotnamectl  
  2. 2. use NetworkManager command line tool: nmcli  
  3. 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:
[html]   view plain   copy
 
  1. [root@localhost ~]# hostnamectl status  
  2.    Static hostname: localhost.localdomain  
  3.          Icon name: computer  
  4.            Chassis: n/a  
  5.         Machine ID: ed264df49f3f42b7b64ca75f763ad117  
  6.            Boot ID: 3ec1705218b9499b9619e1bdca7be737  
  7.     Virtualization: oracle  
  8.   Operating System: Oracle Linux Server 7.1  
  9.        CPE OS Name: cpe:/o:oracle:linux:7:1  
  10.             Kernel: Linux 3.8.13-55.1.6.el7uek.x86_64  
  11.       Architecture: x86_64  

Set hostname:
[html]   view plain   copy
 
  1. [root@localhost ~]# hostnamectl set-hostname oraclelinux.oracle.com  
  2. [root@localhost ~]#  

Re-login terminal session:
[html]   view plain   copy
 
  1. [root@oraclelinux ~]# hostnamectl status  
  2.    Static hostname: oraclelinux.oracle.com  
  3.          Icon name: computer  
  4.            Chassis: n/a  
  5.         Machine ID: ed264df49f3f42b7b64ca75f763ad117  
  6.            Boot ID: 3ec1705218b9499b9619e1bdca7be737  
  7.     Virtualization: oracle  
  8.   Operating System: Oracle Linux Server 7.1  
  9.        CPE OS Name: cpe:/o:oracle:linux:7:1  
  10.             Kernel: Linux 3.8.13-55.1.6.el7uek.x86_64  
  11.       Architecture: x86_64  
2. nmcli
Check current hostname:
[html]   view plain   copy
 
  1. <span style="color:#000000;TEXT-ALIGN: left; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(224,234,241); TEXT-INDENT: 0px; DISPLAY: inline !important; FONT: 11px 'Courier New', Courier, monospace; WHITE-SPACE: normal; FLOAT: none; LETTER-SPACING: normal; WORD-SPACING: 0px; -webkit-text-stroke-width: 0px">[root@localhost ~]# nmcli general hostname</span><br style="TEXT-ALIGN: left; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; FONT: 11px 'Courier New', Courier, monospace; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-text-stroke-width: 0px" /><span style="color:#000000;TEXT-ALIGN: left; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(224,234,241); TEXT-INDENT: 0px; DISPLAY: inline !important; FONT: 11px 'Courier New', Courier, monospace; WHITE-SPACE: normal; FLOAT: none; LETTER-SPACING: normal; WORD-SPACING: 0px; -webkit-text-stroke-width: 0px">localhost.localdomain</span>  
 
Modify hostname and restart ystemd-hostnamed service:
[html]   view plain   copy
 
  1. [root@localhost ~]# nmcli general hostname oraclelinux.oracle.com  
  2. [root@localhost ~]# systemctl restart systemd-hostnamed  

Re-login terminal session:
[html]   view plain   copy
 
  1. [root@oraclelinux ~]# hostname  
  2. oraclelinux.oracle.com  
 
3. Edit /etc/hostname
View current content:
[html]   view plain   copy
 
  1. [root@localhost ~]# cat /etc/hostname  
  2. localhost.localdomain  

Oracle  Linux7中怎么配置hostname?
来源于:
How to Configure hostname in Oracle  Linux  7 (文档 ID 2049221.1)
适用于:
Linux OS - Version Oracle Linux 7.0 and later
Linux x86
Linux x86-64
目标:
本文描述了在Oracle Linux7中修改hostname的方法
注意:手工在/etc/sysconfig/network中追加"HOSTNAME=xxxxx"并重启os,这个方法在Oracle Linux7中是不生效的。
解决方案:
请使用如下三种方法的任何一种来修改Oracle Linux7中的主机名

Replace file content with new hostname:
[html]   view plain   copy
 
  1. [root@localhost ~]# echo "oraclelinux.oracle.com" > /etc/hostname  
  2. [root@localhost ~]# cat /etc/hostname  
  3. oraclelinux.oracle.com  

Restart system and verify:
[html]   view plain   copy
 
  1. [root@oraclelinux ~]# hostname  
  2. oraclelinux.oracle.com  

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值