How to set the hostname of CentOS using the command line?

To set the hostname of CentOS through the command line, you can follow these steps:

  1. Open the terminal or log in to the CentOS server console.
  2. Use the following command to check the current host name:
hostname
  1. Use the following command to permanently set the hostname, replacing “your-hostname” with the desired hostname:
sudo hostnamectl set-hostname your-hostname
  1. Use the following command to immediately apply the change to the hostname:
sudo hostname your-hostname
  1. Verify if the hostname has been changed using the following command:
hostname
  1. Reboot the system to ensure the hostname change has taken effect:
sudo reboot

By following the steps above, you can set the hostname of CentOS using the command line.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds