Linux修改主机名
2021/7/29 7:07:23
本文主要是介绍Linux修改主机名,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
centos6下修改hostname
[root@centos6 ~]$ hostname # 查看当前的hostnmae centos6.magedu.com [root@centos6 ~]$ vim /etc/sysconfig/network # 编辑network文件修改hostname行(重启生效) [root@centos6 ~]$ cat /etc/sysconfig/network # 检查修改 NETWORKING=yes HOSTNAME=centos66.magedu.com [root@centos6 ~]$ hostname centos66.magedu.com # 设置当前的hostname(立即生效) [root@centos6 ~]$ vim /etc/hosts # 编辑hosts文件,给127.0.0.1添加hostname [root@centos6 ~]$ cat /etc/hosts # 检查 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 centos66.magedu.com ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
centos7修改hostname
[root@centos7 ~]$ hostnamectl set-hostname centos77.magedu.com # 使用这个命令会立即生效且重启也生效 [root@centos7 ~]$ hostname # 查看下 centos77.magedu.com [root@centos7 ~]$ vim /etc/hosts # 编辑下hosts文件, 给127.0.0.1添加hostname [root@centos7 ~]$ cat /etc/hosts # 检查 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 centos77.magedu.com ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
这篇关于Linux修改主机名的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-07-04Linux系统上离线升级SSH服务的具体操作步骤-icode9专业技术文章分享
- 2024-06-0600-macOS和Linux安装和管理多个Python版本
- 2024-03-30[译]漫画SELinux概念
- 2024-03-29linux 移动文件
- 2024-03-28linux .so file
- 2024-03-28Linux 磁盘管理
- 2024-03-28Linux学习笔记(十三)磁盘管理(一):磁盘分区
- 2024-03-26linux 创建 文件
- 2024-03-25使用SecureCRT对Linux vim进行颜色设置
- 2024-03-202019-2020-12 20199317 《Linux内核原理与分析》 第十二周作业