CentOS 8 Change Hostname (computer name) command

www.l‮ttua‬uri.com
CentOS 8 Change Hostname (computer name) command

To change the hostname (computer name) on CentOS 8, you can use the following steps:

  1. Edit the file /etc/hostname using a text editor like nano or vi. Replace the current hostname with the new hostname that you want to use. Save and close the file.
sudo nano /etc/hostname
  1. Edit the file /etc/hosts and update the hostname in the line that begins with 127.0.0.1. Replace the current hostname with the new hostname that you want to use. Save and close the file.
sudo nano /etc/hosts
  1. Use the hostnamectl command to set the new hostname. This will update the hostname in the system's configuration and apply the change immediately.
sudo hostnamectl set-hostname new_hostname
  1. If you are using NetworkManager, you may also need to update the hostname in the NetworkManager configuration file. Edit the file /etc/NetworkManager/NetworkManager.conf and update the hostname value to the new hostname. Save and close the file.
sudo nano /etc/NetworkManager/NetworkManager.conf
  1. Finally, restart the NetworkManager service to apply the changes:
sudo systemctl restart NetworkManager

After completing these steps, the hostname of your CentOS 8 system should be changed to the new hostname that you specified. You can verify the hostname by running the hostname command or by checking the output of the uname -n command.

Created Time:2017-10-16 14:38:40  Author:lautturi