How to Change Hostname on Ubuntu 26.10
Displaying the Current Hostname
To find out your current system name, run the following command:
hostnamectl
Output:
root@server:~# hostnamectl
Static hostname: server
Icon name: computer-vm
Chassis: vm 💽
Machine ID: 5e2e02778a384ffbb0f7b52af396ff7c
Boot ID: 5b633750fac74eb9b6b768bcbb935e40
Product UUID: 5e2e0277-8a38-4ffb-b0f7-b52af396ff7c
Virtualization: kvm
Operating System: Ubuntu 26.10
Kernel: Linux 7.3.0-9-generic
Architecture: x86-64
Hardware Vendor: Red Hat
Hardware Model: KVM
Hardware Version: RHEL 7.6.0 PC _i440FX + PIIX, 1996_
Firmware Version: 1.16.0-4.module_el8.9.0+3659+9c8643f3
Firmware Date: Tue 2014-04-01
Firmware Age: 12y 6month 2w 5d
Changing the System Hostname
Now that you know the current hostname, change it by running:
hostnamectl set-hostname vps.crowncloud.net
Replace vps.crowncloud.net with your preferred hostname.
It is also necessary to update the hostname in the /etc/hosts file:
nano /etc/hosts
Modify it like this:
127.0.0.1 localhost
127.0.1.1 vps.crowncloud.net
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
If cloud-init is installed on your Ubuntu server, you may also need to modify the cloud.cfg file to prevent cloud-init from changing the hostname during a reboot:
nano /etc/cloud/cloud.cfg
Find the line:
preserve_hostname: false
Change it to:
preserve_hostname: true
Save the file and exit.
Verifying the Change
To verify that the hostname has been fully changed, run:
hostnamectl
Output:
root@server:~# hostnamectl
Static hostname: vps.crowncloud.net
Icon name: computer-vm
Chassis: vm 💽
Machine ID: 5e2e02778a384ffbb0f7b52af396ff7c
Boot ID: 5b633750fac74eb9b6b768bcbb935e40
Product UUID: 5e2e0277-8a38-4ffb-b0f7-b52af396ff7c
Virtualization: kvm
Operating System: Ubuntu 26.10
Kernel: Linux 7.3.0-9-generic
Architecture: x86-64
Hardware Vendor: Red Hat
Hardware Model: KVM
Hardware Version: RHEL 7.6.0 PC _i440FX + PIIX, 1996_
Firmware Version: 1.16.0-4.module_el8.9.0+3659+9c8643f3
Firmware Date: Tue 2014-04-01
Firmware Age: 12y 6month 2w 5d
That's it! You have successfully changed the hostname on Ubuntu 26.10.
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