Here are the commands and GUI methods to change and set the new hostname on Rocky Linux 8 or AlmaLinux 8 server and desktop distros.
We assigned a unique IP address to distinguish each system over LAN or Internet to identify them easily. However, it is not easy to remember the IP addresses easily, especially when it comes to IPv6, hence to make these things unchallenging we have fully qualified domain names but are limited mostly to Internet systems (public), nevertheless, we can create one to use on local networks only as well. Each domain name corresponds to an IP address, but one IP address can correspond to multiple domain names.
Then what is a hostname?
When we have multiple machines in the local or private networks and to easily recognize or distinguish one from other machines over the same network we assign a name called hostname. This applies even to VMs running in the cloud. Hostname also allows each machine to communicate with each other using the Device name rather than the IP address.
Steps to change hostname in Rocky Linux or AlmaLinux 8
1. Check your current Rocky or AlmaLinux hostname
Before moving forward let’s check what is our current system hostname so that we can confirm later we have successfully changed it.
hostname
Well, the above command print only the current name of your system, however, to get more information use:
hostnamectl
2. Command to change the hostname temporarily
Those who want to change the hostname on their Almalinux or Rocky Linux but temporary for the current session. They can go for the command given below. However, as you restart your system or log out, the set hostname will return to the previous one that had been configured earlier for permanent use.
sudo hostname new-one
Replace the “new-one” in the above command with a hostname that you want to use with your Linux system.
For getting immediate effect on your terminal, you can refresh your session:
newgrp
3. Set hostname permanent without reboot
Now, if you want to change the hostname permanently but without rebooting your Rocky or ALmalinux 8 then go for the hostnamectl
command. The one we used in the beginning to check the detail of the hostname.
sudo hostnamectl set-hostname new-host
newgrp
Replace “new-host” in the above command with the one you want to set.
4. Using /etc/hostname file (reboot required)
Well, the other way to change and set a new hostname is by directly editing a configuration file that holds your current system name
sudo nano /etc/hostname
In the file, delete the current hostname and add the new one you want to set. After that save the file by pressing Ctrl+O, hitting the Enter key, and Ctrl+X.
4. Use GUI to set new Hostname for Almalinux or Rocky Linux 8
Well, there are many people who are using these RHEL based Rocky and AlmaLinux with graphical user interface and also not much comfortable with the command line. So, they can go for the graphical process to change the hostname with just a few clicks.
- Go to Rocky/Almalinux 8 system settings.
- Select the About option given in the menu.
- Click on the Device name box
- Enter the new hostname
- Close the Settings.
Other Articles:
• How to install WHM & CPanel on Ubuntu 20.04 LTS Linux
• Get IP Address in Linux using Command terminal
• Install OpenLiteSpeed Web Server on Rock and AlmaLinux…
• Install Security Patches or Updates Automatically on Almalinux/Rocky…