您好,欢迎来到思海网络,我们将竭诚为您提供优质的服务! 诚征网络推广 | 网站备案 | 帮助中心 | 软件下载 | 购买流程 | 付款方式 | 联系我们 [ 会员登录/注册 ]
促销推广
客服中心
业务咨询
有事点击这里…  531199185
有事点击这里…  61352289
点击这里给我发消息  81721488
有事点击这里…  376585780
有事点击这里…  872642803
有事点击这里…  459248018
有事点击这里…  61352288
有事点击这里…  380791050
技术支持
有事点击这里…  714236853
有事点击这里…  719304487
有事点击这里…  1208894568
有事点击这里…  61352289
在线客服
有事点击这里…  531199185
有事点击这里…  61352288
有事点击这里…  983054746
有事点击这里…  893984210
当前位置:首页 >> 技术文章 >> 文章浏览
技术文章

CentOS7的hostnamectl命令使用详解

添加时间:2019-5-26 17:52:34  添加: 思海网络 
centos7 上在主机名变更新增了一个hostnamectl 指令 ,该指令的无论在输出和更改上都较之前更加的便利。先看下hostname的help帮助信息:




[root@361way ~]# hostnamectl --help
hostnamectl [OPTIONS...] COMMAND ...
Query or change system hostname.
-h --help Show this help
--version Show package version
--transient Only set transient hostname
--static Only set static hostname
--pretty Only set pretty hostname
-P --privileged Acquire privileges before execution
--no-ask-password Do not prompt for password
-H --host=[USER@]HOST Operate on remote host
Commands:
status Show current hostname settings
set-hostname NAME Set system hostname
set-icon-name NAME Set icon name for host
set-chassis NAME Set chassis type for host

查看hostname信息



[root@361way ~]# hostnamectl
Static hostname: 361way
Icon name: computer-desktop
Chassis: desktop
Machine ID: 6917731f5fe447d0bca296ed2802e250
Boot ID: e0d20bc2a3a4474c960394967d33ab53
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.6.3.el7.x86_64
Architecture: x86_64

设置主机名
从上面的help 帮助里可以看到,在设置主机名时,这里涉及到四种主机名,在hostnamectl 的man手册里给予了说明和解释,如下:

This tool distinguishes three different hostnames: the high-level "pretty" hostname which might include all kinds of special characters (e.g. "Lennart's
Laptop"), the static hostname which is used to initialize the kernel hostname at boot (e.g. "lennarts-laptop"), and the transient hostname which might be
assigned temporarily due to network configuration and might revert back to the static hostname if network connectivity is lost and is only temporarily
written to the kernel hostname (e.g. "dhcp-47-11").
Note that the pretty hostname has little restrictions on the characters used, while the static and transient hostnames are limited to the usually accepted
characters of Internet domain names.
更改主机名

一般情况下都是使用set-hostname进行更改:




[root@361way ~]# hostnamectl set-hostname blog

更改主机名一般会涉及到/etc/hostname 、/etc/machine-info 两个文件,同时对于不同的名字修改在man手册上也给了说明:
The static hostname is stored in /etc/hostname, see hostname(5) for more information. The pretty hostname, chassis type, and icon name are stored in /etc/machine-info, see machine-id(5).
set-icon-name 设置的主机一般和图形界面会用到,对应的hostnamectl 输出中的Icon name  ,set-chassis 指定了主机的平台类型,如本机的是desktop,还可以设置为:"desktop", "laptop", "server", "tablet", "handset"



关键字:CentOS7、hostnamectl、命令
分享到:

顶部 】 【 关闭
版权所有:佛山思海电脑网络有限公司 ©1998-2024 All Rights Reserved.
联系电话:(0757)22630313、22633833
中华人民共和国增值电信业务经营许可证: 粤B1.B2-20030321 备案号:粤B2-20030321-1
网站公安备案编号:44060602000007 交互式栏目专项备案编号:200303DD003  
察察 工商 网安 举报有奖  警警  手机打开网站