前言

安装了CentOS7,发现按照以前修改文件/etc/sysconfig/network HOSTNAME字段主机名的方式不生效了,查资料发现可以使用hostnamectl命令

用途

Control the system hostname

用法

hostnamectl [options] {command}

常用选项

--static

the static hostname which is used to initialize the kernel hostname at boot

--transient

he transient hostname which is a default received from network configuration.

--pretty

the high-level "pretty" hostname which might include all kinds of special characters

实践

显示主机名和相关信息

[root@vm-node1 ~]# hostnamectl
Static hostname: vm-node1
Icon name: computer-vm
Chassis: vm
Machine ID: 97a20c207e324ad78ef902d44d77affd
Boot ID: 3663cc8de26b442c9bb84c4a07f4955a
Virtualization: oracle
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-693.el7.x86_64
Architecture: x86-64

  

设置主机名

[root@vm-node1 ~]# hostnamectl --static set-hostname vm-node1

  

参考资料

【1】man hostnamectl

最新文章

  1. C++ 非阻塞套接字的使用 (3)
  2. Visual Studio无法查找或打开 PDB 文件解决办法
  3. 基本linux命令
  4. 【URAL】1960. Palindromes and Super Abilities
  5. noi 2989 糖果
  6. css3制作惊艳hover切换效果
  7. 用SQL语句修复SQL Server数据库
  8. Codeforces Round #313 (Div. 2)B.B. Gerald is into Art
  9. 如何在RedHat6(7) or CentOS6(7)上制作无依赖的PostgreSQL数据库的RPM包
  10. Qt 类外调用一个 private slots 函数
  11. 设置navigationBar上面的item
  12. 【BZOJ 1188】 [HNOI2007]分裂游戏
  13. iOS Mac系统下Ruby环境安装
  14. 《A First Course in Abstract Algebra with Applications》-chaper1-数论
  15. JavaScript DOM编程艺术-学习笔记(第五章、第六章)
  16. springboot整合微软的ad域,采用ldap的api来整合,实现用户登录验证、
  17. jenkins构建任务后发送邮件
  18. Django中间件基础笔记
  19. 设计模式之UML类图六大关系辨析【2】
  20. Django商城项目笔记No.15用户部分-用户中心邮箱验证

热门文章

  1. struts2基础学习----struts.xml配置文件
  2. [Swift通天遁地]五、高级扩展-(14)扩展String快速计算字符串中的各种数学表达式
  3. 牛客小白月赛15 C 表单 ( map 使用)
  4. JavaScript学习四
  5. SQLYog 快捷键
  6. 爬虫—Ajax数据爬取
  7. nginx入门学习
  8. Hadoop Hive概念学习系列之hive里如何显示当前数据库及传参(十九)
  9. C#学习-图片的处理
  10. 初学layer