Change Hostname
The hostname is the name with which the server identifies itself on the network. It should be set correctly especially if the server sends emails or is part of a more complex infrastructure.
View current hostname
hostname
hostnamectl
Change the hostname
hostnamectl set-hostname new-hostname
The hostname must be a valid name: only letters, numbers and hyphens. No spaces or special characters. If you want to use an FQDN (e.g. server1.example.com):
hostnamectl set-hostname server1.example.com
Update /etc/hosts
After changing the hostname, update the /etc/hosts file to avoid slowdowns and warnings:
nano /etc/hosts
Modify the line containing the old hostname. It should be similar to:
127.0.1.1 new-hostname
127.0.1.1 server1.example.com server1
Complete example of /etc/hosts:
127.0.0.1 localhost
127.0.1.1 server1.example.com server1
::1 localhost ip6-localhost ip6-loopback
Verify after change
# Verify short hostname
hostname
# Verify FQDN (fully qualified domain name)
hostname -f
# Verify everything
hostnamectl status
Change hostname from VirtFusion panel
You can also change the hostname directly from the panel:
The change from VirtFusion panel updates the hostname at the VM configuration level, but you still need to update /etc/hostname and /etc/hosts inside the server to make the change effective on the OS.
- Log into VirtFusion panel
- Select server → Options
- Find the Hostname field
- Enter the new hostname and save
Hostname and email
If the server sends email, the hostname affects reputation. Always use a hostname that corresponds to a valid DNS record. See: Reverse DNS
The Reverse DNS (PTR record) should match the server's hostname. Example:
- Hostname: mail.example.com
- PTR record of IP: mail.example.com
- A record: mail.example.com → server IP
Related articles
Server Reboot
How to properly restart your VPS or VDS, both via SSH and from the control panel
Resource Monitoring
How to check CPU, RAM, disk and network on your server in real time
Disk Management
How to check disk space, find large files and free up disk space
