欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 新车 > centos基础设置

centos基础设置

2024/10/25 10:26:41 来源:https://blog.csdn.net/TMise/article/details/141653665  浏览:    关键词:centos基础设置

1.设置网络

# 配置网络
vi /etc/sysconfig/network-scripts/ifcfg-ens33
#将里面的onboard设置为yes

image

2.修改计算机名

使用命令行:
打开终端。 使用 hostnamectl 命令可以直接修改主机名。例如,如果您想将主机名更改为 mynewhostname,您可以使用以下命令:sudo hostnamectl set-hostname mynewhostname这个命令会立即更改主机名,但为了让更改在重启后依然有效,还需要编辑 /etc/hostname 文件。
编辑 /etc/hostname 文件:使用文本编辑器打开 /etc/hostname 文件。您可以使用如 nano 或 vi 的编辑器。例如:
sudo vim /etc/hostname
在文件中,您会看到当前的主机名。将其更改为您想要的新主机名。保存并关闭文件。编辑 /etc/hosts 文件:有时,您还需要在 /etc/hosts 文件中更新主机名。打开该文件:sudo vim /etc/hosts找到与您的旧主机名相关的条目,将其替换为新的主机名。保存并关闭文件。重启网络服务(可选):
为了使更改生效,您可能需要重启网络服务,可以使用以下命令:
sudo systemctl restart network
或者,您可以简单地重启计算机。验证更改:
要验证主机名是否已更改,可以使用 hostnamectl 命令:
hostnamectl
[root@MiWiFi-RD03-srv ~]# sudo hostnamectl set-hostname rocky2024
[root@MiWiFi-RD03-srv ~]# sudo vim /etc/hosts
sudo: vim:找不到命令
[root@MiWiFi-RD03-srv ~]# sudo vi /etc/hosts
[root@MiWiFi-RD03-srv ~]# reboot
Connection closing...Socket close.Connection closed by foreign host.Disconnected from remote host(rocky) at 23:56:51.Type `help' to learn how to use Xshell prompt.
[C:\~]$ Connecting to 172.16.211.215:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.WARNING! The remote SSH server rejected X11 forwarding request.
Activate the web console with: systemctl enable --now cockpit.socketLast login: Thu Aug 29 07:57:25 2024
[root@rocky2024 ~]# cat /etc/hosts
127.0.0.1   rocky2024
::1         rocky2024
[root@rocky2024 ~]#

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com