2015/06/21

在 CENTOS 7 的版本可以使用 hostnamectl 來改變系統 hostname

在 CENTOS 7 的版本可以使用 hostnamectl 來改變系統 hostname
---------------------------
#  hostnamectl 指令用法
[root@dc216979 ~]# 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

# 顯示目前狀態
[root@dc216979 ~]# hostnamectl status
   Static hostname: test.jangmt.com
         Icon name: computer
           Chassis: n/a
        Machine ID: 58ab28939f7f4b849244b1d618da079f
           Boot ID: 4820af9d14a043d8ba6392196fbf7508
    Virtualization: oracle
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-229.4.2.el7.x86_64
      Architecture: x86_64

# 修改主機名稱
[root@dc216979 ~]# hostnamectl set-hostname datanode.jangmt.com

# 顯示目前狀態
[root@dc216979 ~]# hostnamectl status
   Static hostname: datanode.jangmt.com
         Icon name: computer
           Chassis: n/a
        Machine ID: 58ab28939f7f4b849244b1d618da079f
           Boot ID: 4820af9d14a043d8ba6392196fbf7508
    Virtualization: oracle
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-229.4.2.el7.x86_64
      Architecture: x86_64

重開機後,就會正常了。



REF:
http://www.itzgeek.com/how-tos/linux/centos-how-tos/change-default-runlevel-in-centos-7-rhel-7.html 
張貼留言

like