CentOS7系統重新命名

別浪,我們能贏發表於2020-12-16

CentOS7系統重新命名

1、檢視系統版本

[root@test /]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

2、修改名稱
hostnamectl 是在 centos7 中新增加的命令,它是用來修改主機名稱的

[root@test /]# hostnamectl -h
hostnamectl [OPTIONS...] COMMAND ...

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@test /]# hostname
test

更改名稱

[root@test /]# hostnamectl set-hostname newname
[root@test /]# hostname
newname

關閉當前視窗,顯示會生效

相關文章