流觞区直

导航

1.ECS(CentOS7)主机名修改命令

命令:
hostnamectl

使用--help参数查看hostnamectl里面每个参数对应的含义:

[root@localhost ~]# hostnamectl --help

  Query or change system hostname.

  -h --help Show this help
  --version Show package version
  --no-ask-password Do not prompt for password
  -H --host=[USER@]HOST Operate on remote host
  -M --machine=CONTAINER Operate on local container
  --transient Only set transient hostname
  --static Only set static hostname
  --pretty Only set pretty hostname

  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
  set-deployment NAME Set deployment environment for host
  set-location NAME Set location for host //设置本地主机名

接下来进行主机名的重新设置:

[root@localhost ~]# hostnamectl set-hostname C71

断开当前连接:

[root@localhost ~]# exit
logout

Connection closed by foreign host.

重连://连接后会发现主机名称已经修改

Connecting to 192.168.219.129:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Tue Mar 19 20:33:31 2019 from 192.168.219.1
[root@c71 ~]# 

 

posted on 2019-03-20 08:37  流觞区直  阅读(152)  评论(0编辑  收藏  举报