Press "Enter" to skip to content

CentOS7/8和FreeBSD-12修改主机名字

热度 67 度

默认情况下Linux主机的名称是localhost如:

[root@localhost ~]# hostname
localhost.localdomain

修改如下:

 [root@localhost ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

把中间的localhost.localdomain修改成自己的名称:kiccleaf

127.0.0.1 localhost kiccleaf localhost4 localhost4.localdomain4
::1 localhost kiccleaf localhost6 localhost6.localdomain6

[root@localhost ~]# vim /etc/hostname
把localhost名称修改成自己的名称:kiccleaf

重启一下系统

[root@localhost ~]# reboot
Connecting to *.*.*.*:22...
Connection established.
To escape to local shell, press Ctrl+Alt+].

          Welcome to CentOS 8
  _     _            _                 ___
 | |   (_)          | |               / __)
 | |  _ _  ____ ____| | _____ _____ _| |__
 | |_/ ) |/ ___) ___) || ___ (____ (_   __)
 |  _ (| ( (__( (___| || ____/ ___ | | |
 |_| \_)_|\____)____)\_)_____)_____| |_|

Last login: Tue Aug 25 11:57:55 2020 from *.*.*.*
[root@kiccleaf ~]# hostname
kiccleaf

FreeBSD修改名称比较简单

root@localhost:~ # vim /etc/rc.conf
hostname="kiccleaf"
root@localhost:~ # reboot

#重启后连接显示
Connecting to *.*.*.*:22...
Connection established.
To escape to local shell, press Ctrl+Alt+].

Last login: Mon Aug 24 18:06:00 2020 from *.*.*.*
FreeBSD 12.1-RELEASE r354233 GENERIC 
  
      Welcome to FreeBSD!
   _     _            _                 ___
  | |   (_)          | |               / __)
  | |  _ _  ____ ____| | _____ _____ _| |__
  | |_/ ) |/ ___) ___) || ___ (____ (_   __)
  |  _ (| ( (__( (___| || ____/ ___ | | |
  |_| \_)_|\____)____)\_)_____)_____| |_|

root@kiccleaf:~ # uname -a
FreeBSD kiccleaf 12.1-RELEASE FreeBSD 12.1-RELEASE r354233 GENERIC  amd64

发表评论

电子邮件地址不会被公开。 必填项已用*标注