Set Hostname on CentOS

本文将指导您通过四个步骤在CentOS系统中更改主机名:使用hostname命令设置新名称,编辑/hosts文件更新地址,修改/sysconfig/network文件调整配置,最后检查新的主机名。确保操作正确执行以避免系统问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Step 1: Use the hostname utility

Change your hostname to a different name of your choosing. For example:

hostname server01

Step 2: Edit /etc/hosts

Open the /etc/hosts file with your favorite text editor. For example:

nano /etc/hosts

Change the first line and replace your old hostname with the new one. Save the file and exit the editor.

Step 3: Edit /etc/sysconfig/network

This file also contains your hostname. Open the /etc/sysconfig/network file with your favorite text editor.

Change HOSTNAME=vultr to your desired hostname. For example: HOSTNAME=server01.

Step 4: Check your hostname

Run the following command to check your new hostname:

hostname

The new hostname will be displayed in your ssh terminal.


Read more at: https://www.vultr.com/docs/how-to-change-your-hostname-on-centos

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值