The hostname is the human-readable name assigned to your server that identifies it on a network. A properly configured hostname is important for system administration, email delivery, SSL certificates, and logging. This guide explains how to change your server hostname through both the Data Mammoth dashboard and the command line.
Understanding Hostnames
A hostname typically follows the format purpose.yourdomain.com. For example:
web01.example.com— A web serverdb01.example.com— A database servermail.example.com— A mail server
Changing the Hostname via the Dashboard
Data Mammoth allows you to update the server label (display name) directly from the dashboard:
Note that changing the hostname in the dashboard may update the display label only. To ensure the operating system reflects the new hostname, follow the command-line steps below.
Changing the Hostname via Command Line
Using hostnamectl (Recommended)
The hostnamectl command is available on all modern Linux distributions and is the recommended method.
# View current hostname
hostnamectlSet a new hostname
sudo hostnamectl set-hostname web01.example.comVerify the change:
hostnamectlUpdating /etc/hosts
After changing the hostname, update the /etc/hosts file to reflect the new name:
sudo nano /etc/hostsEnsure the file contains a line mapping the hostname to 127.0.1.1 (on Ubuntu/Debian) or 127.0.0.1:
127.0.0.1 localhost
127.0.1.1 web01.example.com web01
203.0.113.10 web01.example.com web01Save and exit.
Ubuntu / Debian
On Ubuntu and Debian, the static hostname is also stored in /etc/hostname:
sudo nano /etc/hostnameReplace the contents with your new hostname:
web01.example.comSave and exit.
CentOS / AlmaLinux
On CentOS and AlmaLinux, hostnamectl handles everything. No additional file edits are required unless you want to update /etc/hosts as described above.
Verifying the Change
After updating the hostname, verify it is applied correctly:
# Check the static hostname
hostnameCheck the fully qualified domain name
hostname -fFull details
hostnamectlYou may need to open a new terminal session or SSH connection to see the updated hostname in your shell prompt.
Hostname Best Practices
Naming Conventions
Choose hostnames that are meaningful and consistent across your infrastructure:
- Use lowercase letters, numbers, and hyphens only.
- Keep it short but descriptive (e.g.,
app01,db-primary). - Include the domain for the FQDN (e.g.,
app01.example.com). - Avoid special characters, spaces, and underscores in hostnames.
- Do not use IP addresses as hostnames.
For Multiple Servers
If you manage several servers, adopt a consistent naming pattern:
| Pattern | Example |
|---|---|
| Role + number | web01, web02, db01 |
| Environment + role | prod-web01, staging-app01 |
| Location + role | us-east-web01, eu-west-db01 |
DNS Considerations
If you set a fully qualified domain name (FQDN) as your hostname, ensure a corresponding DNS A record exists pointing to your server's IP address. This is especially important for:
- Email delivery — Mail servers check that the hostname resolves correctly.
- SSL certificates — Certificates are issued for specific domain names.
- Reverse DNS — The PTR record for your IP should match your hostname for email deliverability. See Server Networking — IPs, DNS, Reverse DNS.
When to Change Your Hostname
Common reasons to update your hostname:
- Initial server setup — Replace the default hostname with a meaningful one.
- Server repurposing — When changing a server's role (e.g., from development to production).
- Domain changes — If you migrate to a new domain name.
- Compliance — Some security standards require descriptive hostnames for audit trails.
Impact of Changing the Hostname
Changing the hostname can affect some services:
- Running services — Most services do not need to be restarted, but some (like Apache, Postfix, or monitoring agents) may reference the old hostname in their configuration.
- SSL certificates — If your certificate was issued for the old hostname, you may need to obtain a new one.
- Monitoring — If you use external monitoring tools, update the hostname reference there as well.
- Logs — The new hostname will appear in new log entries, while old entries retain the previous hostname.
What to Do Next
- Server Networking — IPs, DNS, Reverse DNS — Configure DNS records for your hostname.
- Initial Server Setup — Ubuntu 22.04/24.04 — Complete server setup guide.
- SSL/TLS Certificates — Setup & Renewal — Set up SSL for your domain.
- Organizing Servers with Labels — Label and group your servers.