RHEL / Centos Linux 7:更改和设置Hostname命令
2016-06-01 15:25
686 查看
你可以使用以下的任何工具来管理CentOS Linux7的hostnames:
hostnamectl command : 控制系统的hostname,推荐使用这个。nmtui command : 使用文本用户接口(text user interface (TUI))来控制系统的hostname.
nmcli command : 使用网络管理(NetworkManager)的CLI部分来控制系统的hostname.
hostnames的种类
hostname可以配置为以下几种:1. Static hostname: 由sysadmin分配. 例如 “server1”, “wwwbox2”, or server42.cyberciti.biz.
2. Transient/dynamic hostname: 由DHCP 或 mDNS server在运行时分配.
3. Pretty hostname: 由sysadmin/end-users分配,并且它是自由形态的UTF8 hostname,用了呈现给用户。例如 “Vivek’s netbook”.
方法1: 使用hostnamectl命令
如何显示现在的hostname设置情况
使用命令hostnamectl 或者 hostnamectl status$ hostnamectl
结果
Static hostname: Auto.redhat72.qatest.talend.lan Icon name: computer-vm Chassis: vm Machine ID: 892b6f5b25594ad9b72c89cee1723abf Boot ID: 9e399a2bcc1f4a2fb615aed2dce513d3 Virtualization: vmware Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.2:GA:server Kernel: Linux 3.10.0-327.el7.x86_64 Architecture: x86-64
$ hostnamectl status
结果
Static hostname: Auto.redhat72.qatest.talend.lan Icon name: computer-vm Chassis: vm Machine ID: 892b6f5b25594ad9b72c89cee1723abf Boot ID: 9e399a2bcc1f4a2fb615aed2dce513d3 Virtualization: vmware Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.2:GA:server Kernel: Linux 3.10.0-327.el7.x86_64 Architecture: x86-64
如何设置hostname
# hostnamectl set-hostname Your-New-Host-Name-Here # hostnamectl set-hostname "Your New Host Name Here" --pretty # hostnamectl set-hostname Your-New-Host-Name-Here --static # hostnamectl set-hostname Your-New-Host-Name-Here --transient
如何删除某个hostname
# hostnamectl set-hostname "" # hostnamectl set-hostname "" --static # hostnamectl set-hostname "" --pretty
如何远程设置hostname
# ssh root@server-ip-here hostnamectl set-hostname server1
或者
# hostnamectl set-hostname server1 -H root@192.168.1.42
别的办法就不翻译了,有兴趣请参考
http://www.cyberciti.biz/faq/rhel-redhat-centos-7-change-hostname-command/
相关文章推荐
- Linux 中改变主机名的 4 种方法
- CentOS 7中安装mysql server的步骤分享
- centos 7安装mysql5.5的方法
- centos 7安装mysql5.5和安装 mariadb使用的命令
- Centos7 Mysql 5.6 多主一从 解决方案与详细配置
- 基于Python Shell获取hostname和fqdn释疑
- 阿里云Centos7安装LNMP+wordpress
- CentOS 7安装python3笔记
- Centos7 常用命令
- Centos7 修改主机名
- Centos7 关闭防火墙
- centOS 7 安装nodeJs & mysql 常见问题
- CentOS7上编译多版本PHP并同时运行及systemd设置
- CentOS安装VirtualBox增强功能
- CentOS 7.1 (6.6)PXE网络自动化安装
- linux 修改主机名
- centos7将网卡名字改成eth样式
- 企业运维—CentOS7玩转DHCP服务