To change the hostname on AlmaLinux 9, follow these steps:
Step 1 : Check the current hostname
First, verify the current hostname by running the following command:
Step 2 : Set a new hostname
To change the hostname, use the hostnamectl
command. For example, to set the hostname to server-01
, run:
Step 3 : Verify the new hostname
After setting the hostname, check if the change was applied by running:
Step 4 : Edit /etc/hosts
Next, open the /etc/hosts
file to update the hostname mapping:
Find the line that contains the old hostname and replace it with the new one.
Step 5 : Reboot the system
Finally, reboot your system for the changes to take effect:
Congratulations, you have successfully changed the hostname on your AlmaLinux 9 system!