Change hostname in Rocky Linux 9 via terminal command

May 11, 2024


To change the hostname on a Rocky Linux system, you can use the hostnamectl command, which is a tool for managing system hostnames. Here’s how you can change the hostname:

  1. Open your terminal.
  2. Check the current hostname with this command :

3. Change the hostname by running:

sudo hostnamectl set-hostname new-hostname

Replace new-hostname with the desired hostname you want to set.

After changing the hostname, it’s generally a good idea to restart your system or at least restart the network services to ensure all system components recognize the change. Here’s how you can restart network services:

sudo systemctl restart NetworkManager

This will change the hostname permanently.