Changing the hostname of your Ubuntu 23.10 server is a simple process that can be done using the hostnamectl
command. Whether you want to personalize your system name or match it with your domain, this guide will walk you through the steps to change the hostname on Ubuntu 23.10.
Understanding the Current Hostname
Before you can change the hostname, it’s important to understand what your current system name is. To find out your current hostname, open the terminal and run the following command:
hostnamectl
The output will provide you with 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: b12e449600f14184b7e13199a433a67e Boot ID: 2da169c305a941ad87900de1ed851586 Virtualization: kvm Operating System: Ubuntu 23.10 Kernel: Linux 6.5.0-9-generic Architecture: x86-64 Hardware Vendor: Red Hat Hardware Model: KVM Firmware Version: 1.16.0-3.module_el8.7.0+3346+68867adb Firmware Date: Tue 2014-04-01
Changing the System Hostname
Now that you know the current hostname, you can proceed to change it to your preferred name. To change the hostname, use the following command:
hostnamectl set-hostname new_hostname
Replace new_hostname
with the desired hostname you want to set for your system. For example, if you want to set the hostname as vps.examplecloud.net
, the command would be:
hostnamectl set-hostname vps.examplecloud.net
Make sure to replace vps.examplecloud.net
with your preferred hostname. After running the command, you will need to update the hostname in the /etc/hosts
file to ensure the changes are applied successfully.
Updating the /etc/hosts File
To update the hostname in the /etc/hosts
file, open the file using a text editor. For example, you can use nano
:
sudo nano /etc/hosts
Within the file, locate the line that contains the old hostname and replace it with the new hostname. Here’s an example of how the line should look:
127.0.1.1 new_hostname
Save the file and exit the text editor. The changes will take effect immediately.
If you have cloud-init installed on your Ubuntu server, you will also need to modify the cloud.cfg
file.
sudo nano /etc/cloud/cloud.cfg
Within the file, locate the line preserve_hostname: false
and change it to preserve_hostname: true
. This ensures that the new hostname is preserved during system reboots.
Save the file and exit the text editor.
Verifying the Hostname Change
To verify that the hostname has been successfully changed, you can use the hostnamectl
command once again:
hostnamectl
The output should now display the new hostname. Here’s an example output:
Static hostname: vps.examplecloud.net Icon name: computer-vm Chassis: vm Machine ID: b12e449600f14184b7e13199a433a67e Boot ID: 2da169c305a941ad87900de1ed851586 Virtualization: kvm Operating System: Ubuntu 23.10 Kernel: Linux 6.5.0-9-generic Architecture: x86-64 Hardware Vendor: Red Hat Hardware Model: KVM Firmware Version: 1.16.0-3.module_el8.7.0+3346+68867adb Firmware Date: Tue 2014-04-01
Congratulations! You have successfully changed the hostname on your Ubuntu 23.10 server.
Additional Information
If you’re looking for reliable and scalable cloud hosting solutions, consider Shape.host. They offer Linux SSD VPS services that are tailored to meet the needs of businesses of all sizes. With Shape.host, you can expect top-notch performance, security, and support for your hosting requirements.
Remember, it’s important to always keep your system hostname up to date to ensure smooth communication within your network and to reflect your brand identity. By following the steps outlined in this guide, you can easily change the hostname on your Ubuntu 23.10 server and personalize it to suit your needs.