How to Change Hostname in Rocky Linux 10
Displaying the Current Hostname
Find out the hostname of your system by using the below command,
hostnamectl
Output:
[root@vps ~]# hostnamectl
Static hostname: vps.server.com
Icon name: computer-vm
Chassis: vm 🖴
Machine ID: 67790405611f050c576dcff8bc59a340
Boot ID: 96042ee58e5e42ce90796ab84385cc19
Product UUID: e2349473-ebdc-4044-b3d0-f04941ac5bae
Virtualization: kvm
Operating System: Rocky Linux 10.0 (Red Quartz)
CPE OS Name: cpe:/o:rocky:rocky:10::baseos
OS Support End: Thu 2035-05-31
OS Support Remaining: 9y 11month 1w 6d
Kernel: Linux 6.12.0-55.14.1.el10_0.x86_64
Architecture: x86-64
Hardware Vendor: Red Hat
Hardware Model: KVM
Firmware Version: 1.16.0-4.module_el8.9.0+3659+9c8643f3
Firmware Date: Tue 2014-04-01
Firmware Age: 11y 2month 2w 1d
Changing the System Hostname
Now that you know the current hostname, you can change the hostname by using the following command, and Optionally you can also set the pretty hostname as follows.
hostnamectl set-hostname crowncloud.net
hostnamectl set-hostname "crowncloud production server" --pretty
Next, add the record for the hostname in the /etc/hosts
file.
127.0.0.1 crowncloud.net
Edit the file using your favorite editor.
nano /etc/hosts
After you've added/edited the file, save and exit the file.
Output:
[root@server ~]# cat /etc/hosts
127.0.0.1 crowncloud.net
This will also add an entry to the /etc/hostname
file automatically.
Restart the systemd-hostnamed
service.
systemctl restart systemd-hostnamed
Alternatively Set or Change Hostname using NMTUI
Alternatively, you can set or change the hostname of your system using NetworkManager's Text User Interface. Run the following command and follow the steps as shown below,
nmtui
Select set system hostname.
Enter the new hostname.
Restart the systemd-hostnamed
service.
systemctl restart systemd-hostnamed
Verify the Change
To verify the hostname has been fully changed, enter the hostnamectl
command.
[root@vps ~]# hostnamectl
Static hostname: crowncloud.net
Pretty hostname: crowncloud production server
Icon name: computer-vm
Chassis: vm 🖴
Machine ID: 6a4c71a7b0b084ccac5b956a61183970
Boot ID: 8f9fee2adb0a4f4abac328098a987c98
Product UUID: e2349473-ebdc-4044-b3d0-f04941ac5bae
Virtualization: kvm
Operating System: Rocky Linux 10.0 (Red Quartz)
CPE OS Name: cpe:/o:rocky:rocky:10::baseos
OS Support End: Thu 2035-05-31
OS Support Remaining: 9y 11month 1w 6d
Kernel: Linux 6.12.0-55.14.1.el10_0.x86_64
Architecture: x86-64
Hardware Vendor: Red Hat
Hardware Model: KVM
Firmware Version: 1.16.0-4.module_el8.9.0+3659+9c8643f3
Firmware Date: Tue 2014-04-01
Firmware Age: 11y 2month 2w 1d
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS