Changing the hostname of your AlmaLinux 8 system is a straightforward process that allows you to customize the identity of your server. Whether you want to align it with your brand or make it more memorable, this guide will walk you through the steps to change the hostname. By following these instructions, you can ensure that your server reflects the desired identity and reinforces your professional image.
Checking the Current Hostname
Before changing the hostname, it’s essential to know the current hostname of your system. To check the hostname, open a terminal and use the following command:
hostnamectl
The output will display information about your system, including the current hostname. Here’s an example output:
Static hostname: vps.server.com Icon name: computer-vm Chassis: vm Machine ID: 8adaa7bd77339b01baf08af96bad26e5 Boot ID: 77943c7642974555a05f635b40fa900d Virtualization: kvm Operating System: AlmaLinux 8.3 RC (Purple Manul) CPE OS Name: cpe:/o:almalinux:almalinux:8.3:rc Kernel: Linux 4.18.0-240.15.1.el8_3.x86_64 Architecture: x86-64
Changing the Hostname
Once you have identified the current hostname, you can proceed to change it. AlmaLinux 8 provides two methods to change the hostname: using the hostnamectl
command or the NetworkManager’s Text User Interface (TUI). Let’s explore both options.
Method 1: Using hostnamectl
To change the hostname using the hostnamectl
command, follow these steps:
- Open a terminal and enter the following command to set the new hostname:
sudo hostnamectl set-hostname example.nethostnamectl
Replace example .net
with your desired hostname.
- (Optional) You can also set a pretty hostname for better readability. Use the following command:
sudo hostnamectl set-hostname "example production server" --pretty
Modify the text within the double quotes to match your preferred pretty hostname.
- Next, add the record for the new hostname in the
/etc/hosts
file. Open the file using your favorite editor:
sudo nano /etc/hosts
Add the following entry at the end of the file:
127.0.0.1 example.net
Save and exit the file.
- Restart the
systemd-hostnamed
service to apply the changes:
sudo systemctl restart systemd-hostnamed
By following these steps, you have successfully changed the hostname of your AlmaLinux 8 system using the hostnamectl
command.
Method 2: Using NetworkManager’s TUI
Alternatively, you can change the hostname using NetworkManager’s Text User Interface (TUI) by following these steps:
- Open a terminal and enter the following command to launch the TUI:
sudo nmtui
- In the TUI, select “Set system hostname” and press Enter.
- Enter the new hostname in the designated field and press Enter.
- Exit the TUI by selecting “Quit” and press Enter.
- Restart the
systemd-hostnamed
service to apply the changes:
sudo systemctl restart systemd-hostnamed
Congratulations! You have successfully changed the hostname of your AlmaLinux 8 system using NetworkManager’s TUI.
Verifying the Change
To verify that the hostname has been fully changed, enter the hostnamectl
command in the terminal:
hostnamectl
The output will display the updated hostname information. Here’s an example output:
Static hostname: example.net Pretty hostname: example production server Icon name: computer-vm Chassis: vm Machine ID: 8adaa7bd77339b01baf08af96bad26e5 Boot ID: 77943c7642974555a05f635b40fa900d Virtualization: kvm Operating System: AlmaLinux 8.3 RC (Purple Manul) CPE OS Name: cpe:/o:almalinux:almalinux:8.3:rc Kernel: Linux 4.18.0-240.15.1.el8_3.x86_64 Architecture: x86-64
Ensure that the displayed static hostname and pretty hostname match your desired changes. If they do, you have successfully changed the hostname of your AlmaLinux 8 system.
Conclusion
Customizing the hostname of your AlmaLinux 8 system is a simple yet impactful way to personalize your server and align it with your brand identity. By following the steps outlined in this guide, you can easily change the hostname using either the hostnamectl
command or NetworkManager’s TUI. Remember to verify the changes using the hostnamectl
command to ensure that the new hostname is applied correctly.
Shape.host provides reliable and scalable Linux SSD VPS hosting services. With Shape.host, you can effortlessly change the hostname of your AlmaLinux 8 system and enjoy high-performance cloud hosting solutions. Take control of your server’s identity and experience the power of Shape.host’s cutting-edge infrastructure.