Introduction
When creating a new FastyCloud VPS, you can set the Server Hostname before deployment. If you skip this step or decide to rename your server later, you’ll discover that changing the server hostname from the Customer Portal also performs a fresh reinstall of the entire server.
Follow this guide if you need to change the server hostname without reinstalling.
Supported Versions
This guide should apply to any recently updated version of Arch Linux.
Examples
This guide uses olddog for the old hostname and newtricks for the new hostname.
1. Check the Current Hostname
Check the hostname using the hostnamectl
tool.
$ hostnamectl
Static hostname: olddog
Icon name: computer-vm
Chassis: vm
Machine ID: bcb4587239c44fdca546c15890e88726
Boot ID: 02807656576840d2bc9b8c2b96617803
Virtualization: kvm
Operating System: Arch Linux
Kernel: Linux 5.3.1-arch1-1-ARCH
Architecture: x86-64
Check the hosts file with the getent
tool.
$ getent hosts
127.0.0.1 localhost
127.0.0.1 localhost
127.0.1.1 olddog.localdomain olddog
2. Change Hostname
Change the hostname to newtricks.
sudo hostnamectl set-hostname newtricks
3. Update /etc/hosts
Use your favorite text editor to change any instances of your old hostname to the new hostname in /etc/hosts
. If you have a DNS name pointed to this instance, it’s a best practice to also set that name here.
sudo vim /etc/hosts
From:
127.0.0.1 localhost
::1 localhost
127.0.1.1 olddog.localdomain olddog
To:
127.0.0.1 localhost
::1 localhost
127.0.1.1 newtricks.localdomain newtricks
4. Confirm the Changes
Either reboot the server or log out and back in again to your user session.
Test the change with the hostnamectl
tool.
$ hostnamectl
Static hostname: newtricks
Icon name: computer-vm
Chassis: vm
Machine ID: bcb4587239c44fdca546c15890e88726
Boot ID: 02807656576840d2bc9b8c2b96617803
Virtualization: kvm
Operating System: Arch Linux
Kernel: Linux 5.3.1-arch1-1-ARCH
Architecture: x86-64
Test the change with the getent
tool.
$ getent hosts
127.0.0.1 localhost
127.0.0.1 localhost
127.0.1.1 newtricks.localdomain newtricks
📝 Note: For a system with a permanent IP address, that permanent IP address should be used instead of 127.0.1.1. The order of hostnames in /etc/hosts is significant. The first string is canonical hostname. Subsequent names on the same line are aliases.
Update DNS
Your server hostname is changed and ready to use. This procedure does not change your DNS name, and you’ll need to perform those steps at your domain registrar.